");const V=Q?Q.createHTML(a):a;if(jt===Ye)try{c=new A().parseFromString(V,gr)}catch{}if(!c||!c.documentElement){c=Qe.createDocument(jt,"template",null);try{c.documentElement.innerHTML=hi?De:V}catch{}}const ge=c.body||c.documentElement;return a&&f&&ge.insertBefore(r.createTextNode(f),ge.childNodes[0]||null),jt===Ye?Ne.call(c,St?"html":"body")[0]:St?c.documentElement:ge},Za=function(a){return Dt.call(a.ownerDocument||a,a,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},vi=function(a){return a instanceof w&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof g)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},yi=function(a){return typeof l=="function"&&a instanceof l};function qe(m,a,c){ir(m,f=>{f.call(t,a,c,Ht)})}const Ja=function(a){let c=null;if(qe(de.beforeSanitizeElements,a,null),vi(a))return Ue(a),!0;const f=ae(a.nodeName);if(qe(de.uponSanitizeElement,a,{tagName:f,allowedTags:z}),hr&&a.hasChildNodes()&&!yi(a.firstElementChild)&&ue(/<[/\w!]/g,a.innerHTML)&&ue(/<[/\w!]/g,a.textContent)||hr&&a.namespaceURI===Ye&&f==="style"&&yi(a.firstElementChild)||a.nodeType===lr.progressingInstruction||hr&&a.nodeType===lr.comment&&ue(/<[/\w]/g,a.data))return Ue(a),!0;if(fr[f]||!(dt.tagCheck instanceof Function&&dt.tagCheck(f))&&!z[f]){if(!fr[f]&&Xa(f)&&(X.tagNameCheck instanceof RegExp&&ue(X.tagNameCheck,f)||X.tagNameCheck instanceof Function&&X.tagNameCheck(f)))return!1;if(ui&&!$e[f]){const V=pe(a)||a.parentNode,ge=te(a)||a.childNodes;if(ge&&V){const re=ge.length;for(let ke=re-1;ke>=0;--ke){const Pe=M(ge[ke],!0);V.insertBefore(Pe,oe(a))}}}return Ue(a),!0}return a instanceof u&&!Ud(a)||(f==="noscript"||f==="noembed"||f==="noframes")&&ue(/<\/no(script|embed|frames)/i,a.innerHTML)?(Ue(a),!0):(bt&&a.nodeType===lr.text&&(c=a.textContent,ir([Nt,Ut,Ft],V=>{c=Rt(c,V," ")}),a.textContent!==c&&(or(t.removed,{element:a.cloneNode()}),a.textContent=c)),qe(de.afterSanitizeElements,a,null),!1)},Qa=function(a,c,f){if(Gr[c]||Fa&&(c==="id"||c==="name")&&(f in r||f in Nd))return!1;if(!(si&&!Gr[c]&&ue(v,c))){if(!(Da&&ue(fe,c))){if(!(dt.attributeCheck instanceof Function&&dt.attributeCheck(c,a))){if(!he[c]||Gr[c]){if(!(Xa(a)&&(X.tagNameCheck instanceof RegExp&&ue(X.tagNameCheck,a)||X.tagNameCheck instanceof Function&&X.tagNameCheck(a))&&(X.attributeNameCheck instanceof RegExp&&ue(X.attributeNameCheck,c)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(c,a))||c==="is"&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&ue(X.tagNameCheck,f)||X.tagNameCheck instanceof Function&&X.tagNameCheck(f))))return!1}else if(!fi[c]){if(!ue(Te,Rt(f,Xe,""))){if(!((c==="src"||c==="xlink:href"||c==="href")&&a!=="script"&&Ko(f,"data:")===0&&ja[a])){if(!(Na&&!ue(Ve,Rt(f,Xe,"")))){if(f)return!1}}}}}}}return!0},Fd=S({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xa=function(a){return!Fd[ar(a)]&&ue(Ge,a)},qa=function(a){qe(de.beforeSanitizeAttributes,a,null);const{attributes:c}=a;if(!c||vi(a))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:he,forceKeepAttr:void 0};let V=c.length;for(;V--;){const ge=c[V],{name:re,namespaceURI:ke,value:Pe}=ge,Fe=ae(re),wi=Pe;let se=re==="value"?wi:Bc(wi);if(f.attrName=Fe,f.attrValue=se,f.keepAttr=!0,f.forceKeepAttr=void 0,qe(de.uponSanitizeAttribute,a,f),se=f.attrValue,za&&(Fe==="id"||Fe==="name")&&Ko(se,Ba)!==0&&(Ct(re,a),se=Ba+se),hr&&ue(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,se)){Ct(re,a);continue}if(Fe==="attributename"&&Yo(se,"href")){Ct(re,a);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){Ct(re,a);continue}if(!Ua&&ue(/\/>/i,se)){Ct(re,a);continue}bt&&ir([Nt,Ut,Ft],rs=>{se=Rt(se,rs," ")});const ts=ae(a.nodeName);if(!Qa(ts,Fe,se)){Ct(re,a);continue}if(Q&&typeof $=="object"&&typeof $.getAttributeType=="function"&&!ke)switch($.getAttributeType(ts,Fe)){case"TrustedHTML":{se=Q.createHTML(se);break}case"TrustedScriptURL":{se=Q.createScriptURL(se);break}}if(se!==wi)try{ke?a.setAttributeNS(ke,re,se):a.setAttribute(re,se),vi(a)?Ue(a):$o(t.removed)}catch{Ct(re,a)}}qe(de.afterSanitizeAttributes,a,null)},es=function(a){let c=null;const f=Za(a);for(qe(de.beforeSanitizeShadowDOM,a,null);c=f.nextNode();)qe(de.uponSanitizeShadowNode,c,null),Ja(c),qa(c),c.content instanceof o&&es(c.content);qe(de.afterSanitizeShadowDOM,a,null)};return t.sanitize=function(m){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},c=null,f=null,V=null,ge=null;if(hi=!m,hi&&(m=""),f=c.ownerDocument.importNode(m,!0),f.nodeType===lr.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?c=f:c.appendChild(f);else{if(!zt&&!bt&&!St&&m.indexOf("<")===-1)return Q&&Yr?Q.createHTML(m):m;if(c=Ka(m),!c)return zt?null:Yr?De:""}c&&ci&&Ue(c.firstChild);const re=Za(pr?m:c);for(;V=re.nextNode();)Ja(V),qa(V),V.content instanceof o&&es(V.content);if(pr)return m;if(zt){if(bt){c.normalize();let Pe=c.innerHTML;ir([Nt,Ut,Ft],Fe=>{Pe=Rt(Pe,Fe," ")}),c.innerHTML=Pe}if($r)for(ge=ut.call(c.ownerDocument);c.firstChild;)ge.appendChild(c.firstChild);else ge=c;return(he.shadowroot||he.shadowrootmode)&&(ge=Hr.call(n,ge,!0)),ge}let ke=St?c.outerHTML:c.innerHTML;return St&&z["!doctype"]&&c.ownerDocument&&c.ownerDocument.doctype&&c.ownerDocument.doctype.name&&ue(ra,c.ownerDocument.doctype.name)&&(ke=" `+ke),bt&&ir([Nt,Ut,Ft],Pe=>{ke=Rt(ke,Pe," ")}),Q&&Yr?Q.createHTML(ke):ke},t.setConfig=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_i(m),li=!0},t.clearConfig=function(){Ht=null,li=!1},t.isValidAttribute=function(m,a,c){Ht||_i({});const f=ae(m),V=ae(a);return Qa(f,V,c)},t.addHook=function(m,a){typeof a=="function"&&or(de[m],a)},t.removeHook=function(m,a){if(a!==void 0){const c=Fc(de[m],a);return c===-1?void 0:zc(de[m],c,1)[0]}return $o(de[m])},t.removeHooks=function(m){de[m]=[]},t.removeAllHooks=function(){de=ia()},t}var au=oa();const aa=(e,t)=>{const r=Mc(t),n=e.document.documentElement;n.setAttribute("lang",t),n.setAttribute("dir",r?"rtl":"ltr")},su=(e,t)=>{e.document.title=`${t} | Microsoft Teams`},lu=e=>{e.document.documentElement.classList.add("mica")},cu=e=>{e.document.documentElement.classList.add("flyout")},uu=(e,t)=>la(e,{...sa(["content","focusable","nonce","onclick"],["link","meta","script","#comment","!doctype"],{RETURN_DOM:!1,WHOLE_DOCUMENT:!0}),TRUSTED_TYPES_POLICY:t}),du=(e,t)=>la(e,{...sa(["content","focusable","onclick"],["#comment"],{RETURN_DOM:!0,WHOLE_DOCUMENT:!1,FORCE_BODY:!0}),TRUSTED_TYPES_POLICY:t}),sa=(e,t,r)=>({ADD_ATTR:e,ADD_TAGS:t,RETURN_TRUSTED_TYPE:!0,...r}),la=(e,t)=>au.sanitize(e,t),fu="teams-precache-v2",hu="react-web-client",pu="client-start-failure-count",gu=2;async function ca(e,t){let r=!1,n="unRegisterServiceWorker skipped";if(!("serviceWorker"in e.navigator))return t?.log(`${n}, since ServiceWorker is not available`),!1;try{const i=new URL("serviceworker.js",e.location.href).pathname,o=await e.navigator.serviceWorker.getRegistration(i);if(o)if(await o.unregister())r=await e.caches.delete(fu),r?(e.localStorage.removeItem(`${tn}${rn}`),n="ServiceWorker successfully unregister and cache deleted"):n="Unregister ServiceWorker succeed, but deleting cache failed";else return t?.error("ServiceWorker unregister failed"),!1;else n=`${n}, no active ServiceWorker`}catch(i){return t?.error(`ServiceWorker unregister failed with error: ${i.message}`),!1}return t?.log(n),r}function mu(e,t){const r=ua(e,t);e.localStorage.removeItem(r)}function _u(e,t,r){if(e.navigator?.serviceWorker?.controller?.state!=="activated")return!1;let i=0;const o=ua(e,t);let s=!1;try{const l=e.localStorage.getItem(o);l&&(i=parseInt(l,10)||0),i{this.updateCarouselText(t)},vu)))}showTitleBarIfRequired(){this.platformService.deeplinkTarget!=="flyout"&&this.titleBarHandler.showTitleBar({showActionButtons:this.platformService.isMaglev})}async startPulseAnimation(){const t=this.window.document.getElementById("pre-core-title-bar-logo");t&&t.classList.add("hide");const r=this.window.document.getElementById("loading-screen"),n=this.window.document.getElementById("loading-screen-logo");if(r){this.platformService.platformId===B.Maglev?(n?.classList.add("t2-icon"),r.classList.add("pulse-animation")):n&&(n.classList.add("t2-icon-2025"),n.classList.add("scale-animation-T2_1"),this._animationTimeout=this.window.setTimeout(()=>{n.classList.add("t2-icon-2025-glint")},yu));const i=Ho[this.platformService.locale];i&&r.setAttribute("aria-valuetext",i.loading_aria_label)}}stopPulseAnimationAndHideLoadingScreen(){const t=this.window.document.getElementById("loading-screen"),r=this.window.document.getElementById("loading-screen-logo");if(t){t.setAttribute("aria-hidden","true");const n=({animationName:i})=>{i==="fade-out"&&(t.removeEventListener("animationend",n),t.remove())};this.platformService.platformId===B.Maglev?t.classList.remove("pulse-animation"):r?.addEventListener("animationend",n),t.addEventListener("animationend",n),this.platformService.platformId===B.Maglev?t.classList.add("fade-out-animation"):t.classList.add("fade-out-animation-T2_1")}this.window.clearInterval(this.carouselInterval),this.carouselInterval=void 0}hideErrorScreenElement(){this.window.document.getElementById("error-screen")?.classList.remove("show")}displayError(t){this.window.document.getElementById("error-screen")?.classList.add("show");const n=this.platformService.locale,i=Ho[n];if(!i)return;const o=this.window.document.getElementById("error-title"),s=this.window.document.getElementById("error-description"),l=this.window.document.getElementById("error-action");if(su(this.window,i.oops_error_title),o&&(o.innerText=i.oops_error_title),s){let d=i.oops_error;switch(t){case $t.loadingApp:d=i.oops_loading_error;break;case $t.coreInit:d=i.oops_init_error;break}s.innerText=d}l&&(l.innerText=i.retry_error,l.onclick=this.handleRetry);const u=this.window.document.getElementById("error-action-clear-cache");u&&(u.innerText=i.clear_cache_error,u.onclick=this.handleClearCacheAndRetry)}updateCarouselText(t){this.carouselIndex>0&&this.slideOutCarouselText();const r=this.window.document.getElementsByClassName("text-slider")[0];if(r){const n=this.window.document.createElement("div");n.innerText=t[this.carouselIndex%t.length],n.className="text-slide-in",r.appendChild(n)}this.carouselIndex++}slideOutCarouselText(){this.window.document.getElementsByClassName("text-slide-out")[0]?.remove();const t=this.window.document.getElementsByClassName("text-slide-in")[0];t&&(t.className="text-slide-out")}constructor(t,r,n,i){je(this,"window",void 0),je(this,"platformService",void 0),je(this,"hostCommunication",void 0),je(this,"logger",void 0),je(this,"titleBarHandler",void 0),je(this,"carouselInterval",void 0),je(this,"carouselIndex",void 0),je(this,"_animationTimeout",void 0),je(this,"handleClearCacheAndRetry",void 0),je(this,"handleRetry",void 0),this.window=r,this.platformService=n,this.hostCommunication=i,this.carouselIndex=0,this.handleClearCacheAndRetry=async()=>{await ca(this.window,this.logger),await this.handleRetry()},this.handleRetry=async()=>{this.window.sessionStorage.setItem(D.IsRelaunchFromOOPs,"1"),this.window.location.reload()},this.logger=t.newLogger("PreCoreUiAdapter","frameworks-loader"),this.titleBarHandler=new Rc(this.window,void 0,this.logger,this.hostCommunication)}}function bu(e){return e===B.MaglevT21||e===B.MaglevMacT21||e===B.Web}function yt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Su{async showLoadingScreen(){const t=this.windowManager.getWindow(Fr.Loading);if(!t){this.logger.logNoPii("No loading window will be shown.");return}await this.getOrCreateUiAdapter(t).showLoadingScreen()}showErrorScreen(t){const r=this.getErrorWindow();if(r){const n=this.getOrCreateUiAdapter(r);this.isErrorScreenVisible=!0,n.showErrorScreen(t),this.telemetryService.addUxStatus("FullPageErrorDisplayed"),this.telemetryService.sendNewScenarioThroughONEDS(Gt.ShowPreCoreErrorPage,{reason:t!==void 0?$t[t]:void 0},"show_web_oops_page"),xc(r,this.loggerFactory)}}hideErrorScreen(){if(!this.isErrorScreenVisible)return;const t=this.getErrorWindow();t&&(this.getOrCreateUiAdapter(t).hideErrorScreen(),this.isErrorScreenVisible=!1)}getErrorWindow(){const t=this.windowManager.getWindow(Fr.Error);if(!t){this.logger.warnNoPii("No error window will be shown.");return}return t}getOrCreateUiAdapter(t){return t.preCoreUiAdapter||(t.preCoreUiAdapter=new wu(this.loggerFactory,t,this.platformService,this.hostCommunication)),t.preCoreUiAdapter}constructor(t,r,n,i,o){yt(this,"loggerFactory",void 0),yt(this,"windowManager",void 0),yt(this,"platformService",void 0),yt(this,"telemetryService",void 0),yt(this,"hostCommunication",void 0),yt(this,"logger",void 0),yt(this,"isErrorScreenVisible",void 0),this.loggerFactory=t,this.windowManager=r,this.platformService=n,this.telemetryService=i,this.hostCommunication=o,this.isErrorScreenVisible=!1,this.logger=t.newLogger("PreCoreUiManager","frameworks-loader")}}var cr=function(e){return e.flyout="flyout",e.iFrame="iFrame",e.primary="primary",e.secondary="secondary",e.immersive="immersive",e.notification="notification",e.pip="pip",e}({}),xg=function(e){return e.standAlone="main",e.iframe="iFrame",e.secondary="MW",e.embedded="EDOM",e.worker="Worker",e}({}),da=function(e){return e.flyout="flyout",e.main="main",e.notifications="notifications",e}({}),Pg=function(e){return e.owa="OWA",e.outlook="Outlook",e.officeOnline="OfficeOnline",e.wordWeb="WordWeb",e.word="Word",e.excelWeb="ExcelWeb",e.excel="Excel",e.powerPointWeb="PowerPointWeb",e.powerPoint="PowerPoint",e.lmsBlackBoard="BlackBoard",e.lmsCanvas="Canvas",e.lmsMoodle="Moodle",e.lmsBrightspace="Brightspace",e.lmsOther="OtherLMS",e.lmsOpenLMS="OpenLMS",e.lmsSchoology="Schoology",e.unknown="unknown",e.thirdParty="ThirdParty",e.dynamics="Dynamics",e.onePlayer="OnePlayer",e.devHost="DevHost",e.edge="Edge",e.purview="Purview",e.mesh="Mesh",e}({}),Rg=function(e){return e.userInitiated="userInitiated",e}({}),Wg=h(316925);const Cu="data:image";function Mg(e,t){return new URL(e,t)}function Dg(e,t,r,n){try{return t(new URL(r,n))}catch{return e}}function Ng(e){const t=new URL(e),r="//";return t.protocol+r+t.host}function Ug(e,t){if(!e||!t)return e;try{const r=new URL(e),n=t instanceof URL?t:new URL(t);return r.host=n.host,r.toString()}catch{return e}}function Fg(e){return fa(e)}function zg(e){return fa(e,!0)}function fa(e,t=!1){try{let r=e;r.startsWith("blob:")&&(r=r.replace("blob:",""));const n=Eu(r.toLowerCase()),i=new URL(n);return i?t?(i.pathname||"")+(i.search||"")+(i.hash||""):i.hostname||"":e.toLowerCase()}catch{return e}}function Bg(e,t,r){if(!e)return"";if(e.startsWith("/"))return e;const n=e.indexOf(":");if(n<=0)return"";e=e.replace(/(\')/g,"%27"),e=e.replace(/(\")/g,"%22"),e=e.replace(/{/g,"%7B"),e=e.replace(/}/g,"%7D");const i=e.substring(0,n).toLowerCase();for(const o of t)if(i===o)return o==="blob"&&!r?.some(s=>ku(e,new URL(s)?.origin??""))?"":e;return i==="http"?`https${e.substring(n)}`:""}function Tu(e,t){if(!t)return t;const r=new RegExp(`[?&]${e}=([^&#]*)`).exec(t);return r&&r.length>1?decodeURI(r[1]):""}function jg(e,t,r){if(!e||!t||e.match(new RegExp(`[?&]${t}=`)))return e;const i=`${e.indexOf("?")>=0?"&":"?"}${t}=${r}`;if(e.indexOf("#")!==-1){const o=e.split("#");return`${o[0]}${i}#${o[1]}`}return`${e}${i}`}const ku=(e,t)=>Lu(e)?!1:new RegExp(`^(blob:)(${t})`,"i").test(e),Hg=e=>/^(data:)/i.test(e),Vg=e=>/^(http)(s?):\/\//i.test(e);function Gg(e){if(!e||e.startsWith("/")&&!e.startsWith("//"))return!1;try{return new URL(e).port.length>0}catch{return!1}}const $g=e=>(e.charAt(0)!=="/"&&(e=`/${e}`),e);function Yg(e,t){if(!e||!t)return e;const r=e.indexOf("?");if(r<0)return e;let n=e.indexOf("#");n<0&&(n=e.length);const i=e.substring(n),o=e.substring(0,r),s=e.substring(r+1,n),l=`${encodeURIComponent(t)}=`,u=s.split(/[&;]/g);return forEachRight(u,(d,g)=>{d.lastIndexOf(l,0)!==-1&&u.splice(g,1)}),`${o}${u.length>0?`?${u.join("&")}`:""}${i}`}function Kg(e){return e&&(e.indexOf("#")>=0?e.substring(0,e.indexOf("#")):e)}function Eu(e){return hasProtocol(e)?e:`https://${e}`}const Zg=e=>(e.endsWith("/")||(e+="/"),e),Jg=e=>(e.endsWith("/")&&(e=e.slice(0,-1)),e);function Lu(e){return e.startsWith(Cu)}function Qg(e,t,r,n){try{const i=new URL(e),o=i.pathname.split("/"),s=o.indexOf(r);return s===-1||s+1>=o.length||o[s+1]!==n?e:(o.splice(s+1,0,encodeURIComponent(t)),i.pathname=o.join("/"),i.toString())}catch{return e}}const Iu=(e,t)=>{const r=`theme-${t}`,n=Ou(e);if(n?n!==r&&e.documentElement.classList.replace(n,`theme-${t}`):e.documentElement.classList.add(r),e.defaultView){const i=e.defaultView.getComputedStyle(e.documentElement).getPropertyValue("--themeTitleBarBackgroundColor");Au(e).setAttribute("content",i)}},Ou=e=>{let t;return e.documentElement.classList.forEach(r=>{r.startsWith("theme")&&(t=r)}),t},Au=e=>{let t=e.head.querySelector('meta[name="theme-color"]');return t||(t=e.createElement("meta"),t.setAttribute("name","theme-color"),e.head.appendChild(t)),t};function ct(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ha="about:blank",xu=`${ha}?window=loading`,Pu=`${ha}?minimize=true`;var Ru=function(e){return e[e.None=0]="None",e[e.GlobalWindow=1]="GlobalWindow",e[e.PopoutWindow=2]="PopoutWindow",e[e.MinimizedPopoutWindow=3]="MinimizedPopoutWindow",e}(Ru||{});class Wu{getWindow(t){if(this.visibleWindow)return this.visibleWindow;const r=this.getRequiredWindowType(t);switch(r){case 0:return null;case 2:case 3:this.visibleWindow=this.createPopoutWindow(r);break;case 1:default:this.visibleWindow=this.window,Iu(this.visibleWindow.document,this.platformService.theme),this.writeTemplate(this.visibleWindow,!0);break}return this.platformService.isMaglev&&lu(this.visibleWindow),this.platformService.deeplinkTarget==="flyout"&&cu(this.visibleWindow),this.visibleWindow}getLoadingWindow(){if(this.visibleWindow&&this.platformService.isMaglev){const t=this.visibleWindow;return this.logger.logNoPii("Acquiring the visible window from the loader."),this.visibleWindow=null,t}return null}openWindowRequest(t,r,n){if(this.visibleWindow&&this.platformService.isMaglev){this.logger.logNoPii("Acquiring the visible window from the loader.");const i=this.visibleWindow;this.visibleWindow=null;const{viewportContext:o}=this.platformService;let s;if(t&&(s=Tu("window",t)),!s||this.getWindowTagFromViewportContext(o)===s)return this.resetLoadingWindow(t,r,n),i;i.close()}return this.logger.logNoPii(`url: '${t}' target: '${r}' features: '${n}'`),this.window.open(t,r,n)}createPopoutWindow(t){const r=t===3?Pu:xu;this.logger.logNoPii("Getting loading window from Maglev client:",r);const n=this.window.open(r);if(!n){const i="Could not get loading window.";throw this.logger.errorNoPii(i),new Error(i)}return this.writeTemplate(n),n}getRequiredWindowType(t){const{isMaglev:r,deeplinkTarget:n}=this.platformService;if(this.logger.logNoPii("Determining window type based on:",{purpose:t,isMaglev:r,deeplinkTarget:n}),r){if(n==="core"&&this.config.enableNonRenderingCoreForNativeClient)switch(t){case Fr.Error:return 3;default:return 0}if(this.config.enablePopoutWindowForNativeClient)return 2}return 1}writeTemplate(t,r=!1){const{__webpack_nonce__:n,__webpack_public_path__:i}=this.window,o=i&&`window.__webpack_public_path__="${i}"`,s={theme:this.platformService.theme,environment:this.platformService.environment,cspNonce:n,publicPathScript:o,containerVer:this.config.build,viewportContext:this.platformService.viewportContext,contentOnly:r},l=this.templateGenerator(s);if(r){const u=du(l,this.dompurifyTrustedPolicy);t.document.body.append(...u.childNodes)}else{const u=uu(l,this.dompurifyTrustedPolicy);t.document.write(u),t.document.close()}}async resetLoadingWindow(t,r,n){try{(await this.hostCommunication?.loadModule("core"))?.resetLoadingWindow?.({url:t,windowName:r,windowFeatures:n})}catch(i){this.logger.errorNoPii("Unable to reset loading window:",i)}}getWindowTagFromViewportContext(t){switch(t){case cr.flyout:return da.flyout;case cr.primary:return da.main;default:return}}constructor(t,r,n,i,o,s,l){ct(this,"window",void 0),ct(this,"config",void 0),ct(this,"templateGenerator",void 0),ct(this,"platformService",void 0),ct(this,"hostCommunication",void 0),ct(this,"dompurifyTrustedPolicy",void 0),ct(this,"visibleWindow",void 0),ct(this,"logger",void 0),this.window=t,this.config=r,this.templateGenerator=n,this.platformService=o,this.hostCommunication=s,this.dompurifyTrustedPolicy=l,this.visibleWindow=null,this.logger=i.newLogger("WindowManager","frameworks-loader"),this.dompurifyTrustedPolicy=t.trustedTypes?.createPolicy("@msteams/frameworks-loader#dompurify",{createHTML:u=>u,createScriptURL:()=>""})}}const Mu=(e,t,r,n,i)=>new Ic(e,t,r,n,i),Du=(e,t,r,n,i,o)=>new Wu(e,t,r,n,i,o),Nu=(e,t,r,n,i)=>new Su(e,t,r,n,i),Uu=(e,t,r,n,i)=>new Ss(e,t,r,n,i);function pa(e){return new Promise((t,r)=>{e<0?r(new Error("negative timeout")):setTimeout(t,e)})}function Xg(e,t){return pa(t).then(e)}const ga=/(^|[/?&#])(token=)[^&#/]*/g;function Fu(e){return typeof e=="string"?e.replace(ga,"$1$2"):e instanceof URL?e.href.replace(ga,"$1$2"):e}const zu=(e,t)=>{const r=new URL(e.location.href);if(r.searchParams.has(Wi)){r.searchParams.delete(Wi);try{e.history.replaceState("","",r.href)}catch{t.logNoPii("[removeClientExperienceQspFromUrl] replaceState threw an error")}}};var ma=h(438881),Bu=h.n(ma);function _a(){return new Worker("/v2/worker/precompiled-web-worker-0ad2b20be2d55f0d.js")}function ju(){return new Worker("/v2/worker/precompiled-web-worker-236ae23d03deb9f3.js")}function va(){return new SharedWorker("/v2/worker/precompiled-shared-worker-2ffcf0447ef179d4.js")}function Hu(){return new SharedWorker("/v2/worker/precompiled-shared-worker-f208a1fc04a4134f.js")}var jr=function(e){return e.ag08="ag08",e.ag09="ag09",e.dod="dod",e.gallatin="gallatin",e.gcc="gcc",e.gcchigh="gcchigh",e.life="life",e.prod="prod",e.bleu="bleu",e.delos="delos",e}({});const Vu="precore-worker",ya=(e,t,r,n,i,o,s,l,u,d,g,w,A,$,Y,M=!1,F,oe,te,pe,Q,De,Qe,Dt)=>{const ut=new Date(Date.now());let Ne={experienceName:e,ring:t,environment:r,sessionId:n,platformId:i,buildVersion:o,localeCode:s,workerId:l,preAuthUserId:u,publicPath:w,deviceId:A,isOcdi:$,isPwa:Y,workerChunkLoadMaxRetries:oe,workerChunkLoadRetryDelay:te,workerChunkLoadMaxRetryDelay:pe,shouldFetchWorkerChunksBeforeImportScripts:Q,useDiagnosticsServiceV2:F,turboCohort:De,enableLazyLoadedWorker:Qe,enableMinimalSchemaWorker:Dt,workerCreationTime:ut.getTime(),...M&&{date:`${ut.getMonth()}-${ut.getDate()}`}};return g!==void 0?Ne={...Ne,userConsoleLogLevel:g}:d!==void 0&&(Ne={...Ne,preECSConsoleLogLevel:d}),JSON.stringify(Ne)},qg=e=>e.hash?JSON.parse(decodeURIComponent(e.hash.substr(1))):{};let ur;const Gu=(e,t,r)=>{if(ur)return ur;try{const n=r||"@msteams/core-cdl-worker-common#create-cdl-worker";return ur=window.trustedTypes?.createPolicy(n,{createScriptURL:i=>ba(i,t)}),ur}catch(n){t.errorToTelemetry?.(`Create CDL worker URL trustedType policy failed. This is not a critical error, falling back to function validation. Error ${n}`,"cdl_worker_startup_error_trusted_policy",{endpointUrl:e},!0)}},em=()=>{ur=void 0},wa=(e,t,r,n,i,o,s)=>{class l{constructor(d){const g=n?`${d}#${n}`:d;$u(t,g,!1,typeof e==typeof Worker?"cdlWorker":"cdlsharedWorker",r),i?.(g);const A=Gu(g,t,o);if(A){const Y=A.createScriptURL(g);return s?.(Date.now()),new e(Y)}const $=ba(g,t);return s?.(Date.now()),new e($)}}return l},$u=(e,t,r,n,i)=>{e.log(`{"hostRendererId":${n},"component":${i} Creating CDL Worker with ${r?"passed":"determined"} url ${t} }`)};function ba(e,t){try{const r=new URL(e,Sa().location.origin);let n=!0,i="CDL Web worker URL is invalid.";if(r.origin!==Sa().location.origin&&(i=i.concat("OriginValidationFailed"),n=!1),n)return e;throw new Error(i)}catch(r){t.errorToTelemetry?.("CDL web worker url is not valid","cdl_worker_startup_error_invalid_url",{endpointUrl:e},!0);const n=new Error(r.message);throw n.name="InvalidUrl",n}}function Sa(){return window}function Oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Yu{initPrecoreWorker(t){const r=ya(this.config.experienceName,this.ring,jr[t.environment],t.sessionId,this.platformService.platformId,t.buildVersion,t.locale,this.workerId,t.preAuthUserId,this.platformService.preECSConsoleLogLevel,this.platformService.userConsoleLogLevel,this.webpackPublicPath,t.deviceId,this.platformService.isOcdi,t.isPwa,void 0,this.config.useDiagnosticsServiceV2,this.experienceLoaderSettings.workerChunkLoadMaxRetries,this.experienceLoaderSettings.workerChunkLoadRetryDelay,this.experienceLoaderSettings.workerChunkLoadMaxRetryDelay,this.experienceLoaderSettings.shouldFetchWorkerChunksBeforeImportScripts,this.config.turboCohort,this.experienceLoaderSettings.enableLazyLoadedWorker,this.experienceLoaderSettings.enableMinimalSchemaWorker),n=Worker;Worker=wa(n,this.logger,"ExperienceLoader",r,o=>{this.cdlWorkerUrl=o},"@msteams/frameworks-loader#create-cdl-worker",o=>{this.workerInitializationTime=o});let i;this.experienceLoaderSettings?.enableMinimalSchemaWorker?i=new _a:this.experienceLoaderSettings?.enableLazyLoadedWorker?i=new ju:i=new _a,Worker=n,this.worker=i,i.onerror=o=>{this.logger.error(`Error in worker: ${o.message}`),this.workerErrorBuffer.push(o)}}initPrecoreSharedWorker(t){const r=ya(this.config.experienceName,this.ring,jr[t.environment],this.config.experienceName==="embed-client"?Bu().get("sessionId"):t.sessionId,this.platformService.platformId,t.buildVersion,t.locale,this.workerId,t.preAuthUserId,this.platformService.preECSConsoleLogLevel,this.platformService.userConsoleLogLevel,this.webpackPublicPath,t.deviceId,this.platformService.isOcdi,t.isPwa,this.config.limitCDLSharedWorkerConnectionTimeframe,this.config.useDiagnosticsServiceV2,this.experienceLoaderSettings.workerChunkLoadMaxRetries,this.experienceLoaderSettings.workerChunkLoadRetryDelay,this.experienceLoaderSettings.workerChunkLoadMaxRetryDelay,this.experienceLoaderSettings.shouldFetchWorkerChunksBeforeImportScripts,this.config.turboCohort,this.experienceLoaderSettings.enableLazyLoadedWorker,this.experienceLoaderSettings.enableMinimalSchemaWorker),n=SharedWorker;SharedWorker=wa(n,this.logger,"ExperienceLoader",r,o=>{this.cdlSharedWorkerUrl=o},void 0,o=>{this.workerInitializationTime=o});let i;this.experienceLoaderSettings?.enableMinimalSchemaWorker?i=new va:this.experienceLoaderSettings?.enableLazyLoadedWorker?i=new Hu:i=new va,SharedWorker=n,this.sharedWorker=i,i.onerror=o=>{this.logger.error(`Error in worker: ${o.message}`),this.workerErrorBuffer.push(o)}}getWorkerId(){return this.workerId}getWorker(){return this.worker}getSharedWorker(){return this.sharedWorker}getCdlWorkerUrl(){return this.cdlWorkerUrl}getCdlSharedWorkerUrl(){return this.cdlSharedWorkerUrl}getWorkerInitializationTime(){return this.workerInitializationTime}getWorkerErrorBuffer(){return this.workerErrorBuffer}clearWorker(){this.worker=void 0,this.cdlWorkerUrl=void 0,this.sharedWorker=void 0,this.cdlSharedWorkerUrl=void 0,this.workerInitializationTime=void 0,this.workerId="",this.workerErrorBuffer=[]}constructor(t,r,n,i,o){Oe(this,"config",void 0),Oe(this,"platformService",void 0),Oe(this,"logger",void 0),Oe(this,"experienceLoaderSettings",void 0),Oe(this,"worker",void 0),Oe(this,"workerId",void 0),Oe(this,"sharedWorker",void 0),Oe(this,"cdlWorkerUrl",void 0),Oe(this,"cdlSharedWorkerUrl",void 0),Oe(this,"webpackPublicPath",void 0),Oe(this,"ring",void 0),Oe(this,"workerInitializationTime",void 0),Oe(this,"workerErrorBuffer",void 0),this.config=r,this.platformService=n,this.logger=i,this.experienceLoaderSettings=o,this.workerErrorBuffer=[],this.webpackPublicPath=t.__webpack_public_path__;const s=this.platformService.ring;this.ring=!s||s==="unknown"?"general":s,this.workerId=Vu}}var ie=function(e){return e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Info=3]="Info",e[e.Debug=4]="Debug",e[e.Verbose=5]="Verbose",e[e.Max=6]="Max",e}({});function Ca(e,t){return`${kt}.${t}.${e}`}var dr=function(e){return e[e.None=0]="None",e[e.LoggedInConsole=1]="LoggedInConsole",e[e.AddedIntoDiagnostics=2]="AddedIntoDiagnostics",e[e.ThrottledForDiagnostics=4]="ThrottledForDiagnostics",e[e.SentToTelemetry=8]="SentToTelemetry",e}({});function ni(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Ku="localDebug";class Zu{log(t,...r){return this.invoke(console.log,t,ie.Info,!1,...r)}warn(t,...r){return this.invoke(console.warn,t,ie.Warn,!1,...r)}error(t,...r){const n=this.invoke(console.error,t,ie.Error,!1,...r);return this.diagnosticsService.persistDiagnostics(),n}debug(t,...r){return this.enableDebugLogging?this.invoke(console.debug,t,ie.Debug,!1,...r):dr.None}logNoPii(t,...r){return this.invoke(console.log,t,ie.Info,!0,...r)}warnNoPii(t,...r){return this.invoke(console.warn,t,ie.Warn,!0,...r)}errorNoPii(t,...r){const n=this.invoke(console.error,t,ie.Error,!0,...r);return this.diagnosticsService.persistDiagnostics(),n}debugNoPii(t,...r){return this.enableDebugLogging?this.invoke(console.debug,t,ie.Debug,!0,...r):dr.None}invoke(t,r,n,i,...o){r=_r(`${this.label}: ${r}`);let s=dr.None;if((n<=ie.Warn||this.enableDebugLogging)&&(t.call(console,r,...o),s=s||dr.LoggedInConsole),n0){const l=o.map(u=>Es(u)).join(", ");r=_r(`${r} ${l}`)}this.diagnosticsService.pushDiagnosticsEvent(n,r,i),s=Ls(s,dr.AddedIntoDiagnostics)}return s}constructor(t,r,n){ni(this,"diagnosticsService",void 0),ni(this,"label",void 0),ni(this,"enableDebugLogging",void 0),this.diagnosticsService=r,this.label=n,this.enableDebugLogging=!1;try{this.enableDebugLogging=t.localStorage.getItem(Ku)==="true"}catch{}}}function He(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ii="loaderDiagnostics",Ta="previousLoaderDiagnostics",ka=512,Ju="...",Ea="=====";class Qu{pushDiagnosticsEvent(t,r,n){this._isLoaderCompleted||this.pushDiagnosticsEventInternal(t,r,n)}completeDiagnostics(){this._isLoaderCompleted||(this.persistDiagnostics()&&(this.eventsBufferArray=[]),this._isLoaderCompleted=!0,this.persistDiagnosticsAsPreviousSessionLogs(),this._previousSessionLogsPersisted=!0)}persistDiagnostics(){if(this._isLoaderCompleted)return!1;let t=!1;try{t=this.persistDiagnosticsLogsInternal(this.window.localStorage,this.eventsBufferArray,this.getStorageKey(ii))}catch(r){this.pushDiagnosticsEvent(ie.Error,`LoaderDiagnosticsService: window_localstorage save logs failure, ${r?.name}`,!0)}return t}getDiagnosticsEvents(){return Promise.resolve(this.eventsBufferArray)}async getLogsFiles(t){const r=this.getLogsFromLocalStorage(this.window.localStorage,this.getStorageKey(Ta),!!t);let n="";return this._isLoaderCompleted&&this.eventsBufferArray.length===0?n=this.getLogsFromLocalStorage(this.window.localStorage,this.getStorageKey(ii),!!t):n=await this.getDiagnosticsLogs(!!t),Promise.resolve([{isPiiFree:!0,fileName:"loader-diagnostics-logs-previous-session.txt",content:r||"No logs found"},{isPiiFree:!0,fileName:"loader-diagnostics-logs.txt",content:n||"No logs found"}])}getSystemInfo(){return Promise.resolve(new Map)}persistDiagnosticsAsPreviousSessionLogs(){if(!(this._previousSessionLogsPersisted&&this._isLoaderCompleted))try{let t=this.eventsBufferArray;if(this._isLoaderCompleted&&t.length===0){const r=this.getLogsArrayFromLocalStorage(this.window.localStorage,this.getStorageKey(ii),!0);r&&r.logsArray.length>0&&(t=r.logsArray)}t.length>0&&this.persistDiagnosticsLogsInternal(this.window.localStorage,t,this.getStorageKey(Ta))}catch(t){this.pushDiagnosticsEvent(ie.Error,`LoaderDiagnosticsService: persist previous session logs failure, ${t?.name}`,!0)}}setSessionId(t){this._sessionId=t}addEvent(t){this.eventsBufferArray.length>=this.DEFAULT_QUEUE_CAPACITY&&this.eventsBufferArray.shift(),this.eventsBufferArray.push(t)}async getDiagnosticsLogs(t){const r=await this.getDiagnosticsEvents();return this.formatEvents(t?this.filterLogsForPiiFreeOnly(r):r)}filterLogsForPiiFreeOnly(t){return t.length?t.filter(r=>r.isPiiFree):t}formatEvents(t){if(!t||t.length===0)return"";let r="";const n=3;return t.forEach(i=>{if(i)if(i.message?.startsWith(Ea)&&i.message?.endsWith(Ea))r+=` ${i.message}\r `;else{const o=typeof i.timeStamp?.toISOString=="function"?i.timeStamp.toISOString():i.timeStamp,s=typeof i.levelName=="string"?i.levelName.substring(0,n):"unknownLevelName";r+=`${o} ${s} ${i.message}\r `}}),_r(r)}persistDiagnosticsLogsInternal(t,r,n){let i=!1;if(!t)return i;try{const o=Ui({sessionId:this._sessionId,logsArray:r});t.setItem(n,o),i=!0}catch{}return i}convertToDiagnostisEvent(t){const r={message:`DiagnosticsService - Converting event from localStorage failed - ${t}`,isPiiFree:!0,level:ie.Error,levelName:"error",timeStamp:new Date};try{const n=t;if("timeStamp"in n){if(typeof n.timeStamp=="string")if(!isNaN(Date.parse(n.timeStamp)))n.timeStamp=new Date(n.timeStamp);else return r;return n}}catch{}return r}pushDiagnosticsEventInternal(t,r,n,i){r.length>ka&&(r=r.substring(0,ka)+Ju),r=_r(r);const o={message:r,level:t,levelName:ie[t],timeStamp:i||new Date,isPiiFree:n};return this.addEvent(o),o}getLogsFromLocalStorage(t,r,n){let i="";try{const o=this.getLogsArrayFromLocalStorage(t,r,!1);o&&o.logsArray.length>0&&(n&&(o.logsArray=this.filterLogsForPiiFreeOnly(o.logsArray)),i=this.formatEvents(o.logsArray))}catch{i="Session logs parsing failed"}return i}getLogsArrayFromLocalStorage(t,r,n){let i=t.getItem(r);if(i)try{const o=JSON.parse(i);if(i=null,o)return n&&t.removeItem(r),"logsArray"in o?{sessionId:o.sessionId,logsArray:o.logsArray.map(s=>this.convertToDiagnostisEvent(s))}:{sessionId:"",logsArray:o}}catch{}}constructor(t,r){He(this,"window",void 0),He(this,"loaderConfig",void 0),He(this,"DEFAULT_QUEUE_CAPACITY",void 0),He(this,"eventsBufferArray",void 0),He(this,"_previousSessionLogsPersisted",void 0),He(this,"_isLoaderCompleted",void 0),He(this,"_sessionId",void 0),He(this,"logsProviderName",void 0),He(this,"newLogger",void 0),He(this,"getStorageKey",void 0),this.window=t,this.loaderConfig=r,this.DEFAULT_QUEUE_CAPACITY=200,this.eventsBufferArray=[],this._previousSessionLogsPersisted=!1,this._isLoaderCompleted=!1,this._sessionId="",this.logsProviderName="LoaderDiagnosticsService",this.newLogger=n=>new Zu(this.window,this,`[ExpLoader] ${n}`),this.getStorageKey=n=>Ca(n,this.loaderConfig.experienceName),t?.addEventListener&&(t.addEventListener("visibilitychange",()=>{t.document?.hidden&&this.persistDiagnosticsAsPreviousSessionLogs()}),t.addEventListener("pagehide",()=>{this.persistDiagnosticsAsPreviousSessionLogs()}))}}const La={"az-az":"az-latn-az","be-by":"ru-ru","de-at":"de-de","de-ch":"de-de","de-li":"de-de","de-lu":"de-de","en-029":"en-us","en-au":"en-gb","en-bz":"en-us","en-ca":"en-gb","en-ie":"en-gb","en-in":"en-gb","en-jm":"en-us","en-my":"en-gb","en-nz":"en-gb","en-ph":"en-us","en-sg":"en-gb","en-tt":"en-us","en-za":"en-gb","en-zw":"en-gb","es-419":"es-es","es-ar":"es-mx","es-bo":"es-mx","es-cl":"es-mx","es-co":"es-mx","es-cr":"es-mx","es-do":"es-mx","es-ec":"es-mx","es-gt":"es-mx","es-hn":"es-mx","es-ni":"es-mx","es-pa":"es-mx","es-pe":"es-mx","es-pr":"es-mx","es-py":"es-mx","es-sv":"es-mx","es-us":"es-mx","es-uy":"es-mx","es-ve":"es-mx","fl-ip":"en-us","fr-be":"fr-fr","fr-ch":"fr-fr","fr-lu":"fr-fr","fr-mc":"fr-fr","it-ch":"it-it","iu-latn":"iu-latn-ca","ky-kg":"ru-ru","lb-lu":"de-de","mn-mong":"mn-mong-mn","nl-be":"nl-nl","qut-gt":"es-es","quz-pe":"es-es","sr-cyrl":"sr-cyrl-rs","sr-latn":"sr-latn-rs","sr-rs":"sr-latn-rs","sv-fi":"sv-se","tg-cyrl-tj":"ru-ru","tk-tm":"ru-ru","tt-ru":"ru-ru","ug-cn":"zh-cn","uz-cyrl-uz":"uz-latn-uz","wo-sn":"fr-fr","zh-chs":"zh-cn","zh-cht":"zh-tw","zh-hans-cn":"zh-cn","zh-hans-sg":"zh-cn","zh-hans":"zh-cn","zh-hant-hk":"zh-tw","zh-hant-mo":"zh-tw","zh-hant-tw":"zh-tw","zh-hant":"zh-tw","zh-hk":"zh-tw","zh-mo":"zh-tw","zh-sg":"zh-cn",af:"af-za",am:"am-et",ar:"ar-sa",as:"as-in",az:"az-latn-az",ba:"ba-ru",bg:"bg-bg",bo:"bo-cn",brx:"brx-in",bs:"bs-latn-ba",ca:"ca-es",cs:"cs-cz",cy:"cy-gb",da:"da-dk",de:"de-de",dsb:"dsb-de",dv:"dv-mv",el:"el-gr",en:"en-us",es:"es-es",et:"et-ee",eu:"eu-es",fa:"fa-ir",fi:"fi-fi",fil:"fil-ph",fo:"fo-fo",fr:"fr-fr",ga:"ga-ie",gl:"gl-es",gu:"gu-in",ha:"ha-latn-ng",he:"he-il",hi:"hi-in",hr:"hr-hr",hsb:"hsb-de",hu:"hu-hu",hy:"hy-am",id:"id-id",ig:"ig-ng",is:"is-is",it:"it-it",ja:"ja-jp",ka:"ka-ge",kk:"kk-kz",km:"km-kh",kn:"kn-in",ko:"ko-kr",ks:"ks-deva-in",ky:"ky-kg",ln:"ln-cd",lo:"lo-la",lt:"lt-lt",lv:"lv-lv",mg:"mg-mg",mi:"mi-nz",mk:"mk-mk",ml:"ml-in",mni:"mni-in",mr:"mr-in",ms:"ms-my",mt:"mt-mt",my:"my-mm",nb:"nb-no",ne:"ne-np",nl:"nl-nl",nn:"nn-no",or:"or-in",pa:"pa-in",pl:"pl-pl",prs:"prs-af",pt:"pt-br",ro:"ro-ro",ru:"ru-ru",rw:"rw-rw",sd:"sd-deva-in",si:"si-lk",sk:"sk-sk",sl:"sl-si",so:"so-so",sq:"sq-al",sr:"sr-latn-rs",st:"st-ls",sv:"sv-se",sw:"sw-tz",ta:"ta-in",te:"te-in",th:"th-th",ti:"ti-et",tk:"tk-tm",tn:"tn-bo",to:"to-to",tr:"tr-tr",tt:"tt-ru",uk:"uk-ua",ur:"ur-pk",uz:"uz-latn-uz",vi:"vi-vn",yo:"yo-ng",zh:"en-us",zu:"zu-za"},Xu=["sq-al","af-za","ar-sa","az-latn-az","eu-es","bg-bg","bs-latn-ba","ca-es","zh-cn","zh-sg","zh-hk","zh-mo","zh-tw","hr-hr","cs-cz","da-dk","nl-be","nl-nl","en-au","en-bz","en-ca","en-029","en-in","en-ie","en-jm","en-my","en-nz","en-ph","en-sg","en-za","en-tt","en-gb","en-us","en-zw","et-ee","fa-ir","fil-ph","fi-fi","fr-be","fr-ca","fr-fr","fr-lu","fr-mc","fr-ch","gl-es","ka-ge","de-at","de-de","de-li","de-lu","de-ch","el-gr","he-il","hi-in","hu-hu","is-is","id-id","it-it","it-ch","ja-jp","kk-kz","km-kh","ko-kr","lo-la","lv-lv","lt-lt","mk-mk","ms-my","mt-mt","nb-no","nn-no","pl-pl","pseudo","pseudo_rtl","pt-br","pt-pt","ro-ro","fl-ip","ru-ru","sr-cyrl-rs","sr-latn-rs","sk-sk","sl-si","es-ar","es-ve","es-bo","es-cl","es-co","es-cr","es-do","es-ec","es-sv","es-gt","es-hn","es-mx","es-ni","es-py","es-pa","es-pe","es-pr","es-es","es-us","es-uy","sv-fi","sv-se","th-th","tr-tr","uk-ua","uz-latn-uz","ca-es-valencia","vi-vn","cy-gb"],tm=e=>{for(const t of e){const r=Ia(t);if(r.locale!==null)return r.originalLocale=e.toLocaleString(),r}return{locale:"en-us",reason:"No supported language found - falling back to en-us",originalLocale:e.toLocaleString()}},oi=e=>{const t=Ia(e);return t.locale!==null?t:{locale:"en-us",reason:"No supported language found - falling back to en-us",originalLocale:e}},Ia=e=>{const t=e.trim().toLowerCase();let r=ed(t);return La[r]?(r=La[r],{locale:r,reason:"Found in fallback table",originalLocale:e}):qu(r)?{locale:r,reason:"Supported language"}:{locale:null,reason:"Didn't find supported language.",originalLocale:e}},qu=e=>{const t=e.toLowerCase();for(const r of Xu)if(t===r.toLowerCase())return!0;return!1},ed=e=>{const r=new Date().getTimezoneOffset(),n=120,i=420;return e==="fr"&&r>=n&&r<=i?"fr-ca":e},rm=e=>e.reason==="Supported language"||e.reason==="Found in fallback table",nm=e=>{let t=e&&getAvailableLanguageByCode(e,!0);if(!t){const r=oi(e||"")?.locale;t=getAvailableLanguageByCode(r,!0)}return t||getAvailableLanguageByCode("en-us",!0)||{header:"English (United States)",code:"en-us","data-tid":"language-en-us",name:"English (United States)"}},im=e=>e.replace(/\s*\([^)]*\)/g,"");var om=function(e){return e.Windows="windows",e.Mac="mac",e.Linux="linux",e.ChromeOS="chromeos",e.Android="android",e.IOS="ios",e.WindowsPhone="windowsphone",e.Unknown="unknown",e}({}),Me=function(e){return e.Default="default",e.DefaultV2="defaultV2",e.DefaultTfl="tfl-default",e.Dark="dark",e.DarkV2="darkV2",e.DarkTfl="tfl-dark",e.HighContrast="contrast",e.Classic="classic",e}({}),wt=function(e){return e.Dark="dark",e.Light="light",e.Contrast="contrast",e}({}),am=function(e){return e.Light="0",e.Dark="1",e.Contrast="2",e.DefaultV2="3",e.DarkV2="4",e.DefaultTfl="5",e.DarkTfl="6",e}({}),sm=function(e){return e.HighContrast="#FFFFFF_#000000_#FFFF00",e}({}),Mt=function(e){return e.ColorContrastOverride="(forced-colors: active)",e.Light="(prefers-color-scheme: light)",e.Dark="(prefers-color-scheme: dark)",e}({});const td="tmp.desktopTheme",rd=(e,t)=>{try{if(e.matchMedia(Mt.ColorContrastOverride).matches)return t?.log(`OS Theme Matches: ${Mt.ColorContrastOverride}`),wt.Contrast;const r=e.localStorage.getItem(td);return r||(e.matchMedia(Mt.Dark).matches?(t?.log(`OS Theme Matches: ${Mt.Dark}`),wt.Dark):e.matchMedia(Mt.Light).matches?(t?.log(`OS Theme Matches: ${Mt.Light}`),wt.Light):(t?.log("OS Theme Matches: None. Returning theme type light."),wt.Light))}catch(r){t?.log(`Couldn't resolve getOsTheme: ${r.message}`);return}},nd=e=>({[wt.Light]:e===jr.life?Me.DefaultTfl:Me.DefaultV2,[wt.Dark]:e===jr.life?Me.DarkTfl:Me.DarkV2,[wt.Contrast]:Me.HighContrast}),Oa=(e,t)=>t[e]||Me.DefaultV2,id=()=>({[Theme.Default]:ThemeType.Light,[Theme.DefaultV2]:ThemeType.Light,[Theme.DefaultTfl]:ThemeType.Light,[Theme.Dark]:ThemeType.Dark,[Theme.DarkV2]:ThemeType.Dark,[Theme.DarkTfl]:ThemeType.Dark,[Theme.HighContrast]:ThemeType.Contrast,[Theme.Classic]:ThemeType.Light}),od=(e,t)=>t[e]||ThemeType.Light,lm=e=>od(e,id()),cm=(e,t,r,n)=>{const i=e.getPreferences("theme")??{};return Aa(i,t,r,n)},Aa=(e,t,r,n)=>{const i=ad(t);if(i)return i;if(e.followOsTheme){const o=rd(t,n);if(o)return Oa(o,r)}else{if(e.isClassicTheme)return Me.Classic;if(e.userTheme)return Oa(e.userTheme,r)}return Me.DefaultV2},ad=e=>{const r=new URLSearchParams(e.location.search).get("theme");if(r){const n=Object.keys(Me).find(i=>i.toUpperCase()===r.toUpperCase());return Me[n]}};function H(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const sd="buildNumber",ld="logLevel",cd="(display-mode: standalone) or (display-mode: window-controls-overlay)";class ud{get environment(){return this._environment===void 0&&(this._environment=ls(this.window,this._headConfig)),this._environment}get pdsEnvironment(){return this._headConfig?.pdsEnvironment}get indexVersionQSP(){return this._indexVersionQSP===void 0&&(this._indexVersionQSP=this.getindexVersionQSP()),this._indexVersionQSP}get isMaglev(){return this._isMaglev===void 0&&(this._isMaglev=Li(this.window)),this._isMaglev}get platformId(){return this._platformId===void 0&&(this._platformId=this.isMaglev?ss(this.window):B.Web),this._platformId}get isOcdi(){return!!this.headConfig?.isOcdi}get enableSriForDynamicImports(){return this.headConfig.disableSriDI?!1:this.headConfig.unauthenticated?!!this.headConfig.enableSriDIUnauthenticated:!0}get enableEarlyServiceWorkerRegistration(){return!!this.headConfig.enableEarlyServiceWorkerRegistration}get isPwa(){return!!this.window.matchMedia(cd).matches}get deeplinkTarget(){return this._deeplinkTarget===void 0&&(this._deeplinkTarget=this.getHashItem("deepLink")),this._deeplinkTarget}get viewportContext(){return this._viewportContext===void 0&&(this.deeplinkTarget==="flyout"?this._viewportContext=cr.flyout:this._viewportContext=cr.primary),this._viewportContext}get theme(){return this._theme===void 0&&(this._theme=this.getTheme()),this._theme}get locale(){return this._locale===void 0&&(this._locale=this.detectLocale()),this._locale}get bootType(){return this._bootType===void 0&&(this._bootType=this.getBootTypeInternal()),this._bootType}get buildVersion(){return this.config?.build||this._headConfig?.buildVersion||""}get ring(){if(this.bootType===y.Local){const r=this.getRingFromQSP();if(r)return r}const t=this._headConfig?.ring;return t?typeof t=="string"?t:t.id||"unknown":"unknown"}getCookieByName(t){return ma.get(t)}get headConfig(){return this._headConfig||(this._headConfig=Ei(this.window,this.logger)),this._headConfig}get deeplinkId(){return this._deeplinkId===void 0&&(this._deeplinkId=this.getHashItem("deeplinkId")),this._deeplinkId}get networkState(){return this._networkState==="suspectedOnline"&&!this.window.navigator.onLine&&(this._networkState="unstable"),this._networkState}get preECSConsoleLogLevel(){if(this.userConsoleLogLevel===void 0){if(this._preECSConsoleLogLevel===void 0)if(this.bootType===y.Local)this._preECSConsoleLogLevel=ie.Warn;else{let t=this.ring;const r=this.getRingFromQSP();r&&(t=r),t.indexOf("general")>=0||t.indexOf("ring3")>=0?this._preECSConsoleLogLevel=ie.None:this._preECSConsoleLogLevel=ie.Warn}return this._preECSConsoleLogLevel}}get userConsoleLogLevel(){if(this._userConsoleLogLevel===void 0)try{const t=this.window.localStorage.getItem(ld);if(t){const r=parseInt(t,10);r>=ie.None&&r<=ie.Max&&(this._userConsoleLogLevel=r)}}catch{this.logger?.warnNoPii("The `logLevel` value in localStorage is not valid")}return this._userConsoleLogLevel}get activeServiceWorkerVersion(){return this._activeServiceWorkerVersion}get activeServiceWorkerVersionPromise(){return this._getServiceWorkerVersionPromise}cleanUpNetworkStateListener(){this.window.removeEventListener("online",this.onlineHandler),this.window.removeEventListener("offline",this.offlineHandler)}getTheme(){const t=nd(this.environment);return Aa(this.getThemeValueFromStorage(),this.window,t,this.logger)}getBootTypeInternal(){const t=this.config?.build,r=this.config?.experienceName;if(!t)return this.logger?.errorNoPii("build number is missing"),y.Unknown;if(!r)return this.logger?.errorNoPii("experience name is missing"),y.Unknown;const n=this.window.localStorage.getItem(Ca(sd,r)),i=this.getAppBootType(t,n);return i===y.Unknown?this.logger?.errorNoPii(`Build Number Format Is Invalid. CurrentBuildNumber: ${t}, PreviousBuildNumber: ${n}`):this.logger?.logNoPii(`App boot type: ${i}`),i}getAppBootType(t,r){if(t&&t.toLowerCase().startsWith("local"))return y.Local;if(t&&t.toLowerCase().includes("oncdn"))return y.Container;if(r){if(r.toLowerCase().startsWith("local"))return y.Cold;if(r.toLowerCase().includes("oncdn"))return y.Cold}if(!Vt(this.window))return y.Cold;if(!r)return y.Warm;const n=Number(t),i=Number(r);return isNaN(n)||isNaN(i)?y.Unknown:ni?y.Update:y.Warm}getindexVersionQSP(){let t="";const r=new URL(this.window.location.href);return r.searchParams.get("container")&&(t=`${t};container`),r.searchParams.get("version")&&(t=`${t};version`),r.searchParams.get("ring")&&(t=`${t};ring`),r.searchParams.get("clearcontainer")&&(t=`${t};clearcontainer`),t.length>0?t.substring(1):""}getHashItem(t){if(this._urlSearchParams===void 0){let r=this.window.location.hash||"";r.startsWith("#")&&(r=r.substr(1)),this._urlSearchParams=new URLSearchParams(decodeURIComponent(r))}return this._urlSearchParams.get(t)}setInitConsoleLogLevel(){this.window.defaultConsoleLogLevel||(this.window.defaultConsoleLogLevel={userConsoleLogLevel:this.userConsoleLogLevel,preECSConsoleLogLevel:this.preECSConsoleLogLevel})}getThemeValueFromStorage(){const t="local-user-preferences",r=`tmp.${this.config?.experienceName}.${t}`;if(r){const n=this.window.localStorage.getItem(r);if(n)return JSON.parse(n).theme}return{}}setUpNetworkStateListener(){this._networkState=this.window.navigator.onLine?"suspectedOnline":"suspectedOffline",this.window.addEventListener("online",this.onlineHandler),this.window.addEventListener("offline",this.offlineHandler)}getRingFromQSP(){const t=this.window.location.search;return!this._headConfig?.isInternalUser||!t?null:new URLSearchParams(t).get("ring")}readSettingsFromUrlHash(){try{const t=this.getHashItem("theme");t?new Set(Object.values(Me)).has(t)?this._theme=t:(this._theme=void 0,this.logger?.warnNoPii("Invalid theme value ignored from URL hash")):this._theme=void 0;const r=this.getHashItem("language");this._migratedLocale=r||void 0,this.logger?.logNoPii(`${this._migratedLocale} locale and ${this._theme} theme parsed from URL hash`)}catch(t){this.logger?.errorNoPii(`Failed to parse theme and language settings from URL hash - ${t.message}`)}}setServiceWorkerVersion(){this.window.navigator.serviceWorker?.controller?(this._getServiceWorkerVersionPromise=ds(this.window,this.window.navigator.serviceWorker?.controller,this.logger),this._getServiceWorkerVersionPromise.then(r=>{this._activeServiceWorkerVersion=r})):this._activeServiceWorkerVersion=""}setPlatformIdCookie(){try{const t=new Date;t.setFullYear(t.getFullYear()+1),this.window.document.cookie=`platformId=${this.platformId}; expires=${t.toUTCString()}`,this.logger?.logNoPii?.(`Setting platformId cookie ${this.platformId}.`)}catch{this.logger?.errorNoPii?.("Setting platformId cookie failed.")}}constructor(t,r,n){H(this,"window",void 0),H(this,"config",void 0),H(this,"logger",void 0),H(this,"_bootType",void 0),H(this,"_deeplinkId",void 0),H(this,"_deeplinkTarget",void 0),H(this,"_environment",void 0),H(this,"_headConfig",void 0),H(this,"_isMaglev",void 0),H(this,"_locale",void 0),H(this,"_migratedLocale",void 0),H(this,"_platformId",void 0),H(this,"_theme",void 0),H(this,"_urlSearchParams",void 0),H(this,"_viewportContext",void 0),H(this,"_preECSConsoleLogLevel",void 0),H(this,"_userConsoleLogLevel",void 0),H(this,"_networkState",void 0),H(this,"_activeServiceWorkerVersion",void 0),H(this,"_indexVersionQSP",void 0),H(this,"_getServiceWorkerVersionPromise",void 0),H(this,"detectLocale",void 0),H(this,"onlineHandler",void 0),H(this,"offlineHandler",void 0),this.window=t,this.config=r,this.logger=n,this._bootType=void 0,this._deeplinkId=void 0,this._deeplinkTarget=void 0,this._environment=void 0,this._headConfig=void 0,this._isMaglev=void 0,this._locale=void 0,this._migratedLocale=void 0,this._platformId=void 0,this._theme=void 0,this._urlSearchParams=void 0,this._viewportContext=void 0,this._preECSConsoleLogLevel=void 0,this._userConsoleLogLevel=void 0,this._networkState="unknown",this._activeServiceWorkerVersion=void 0,this._indexVersionQSP=void 0,this._getServiceWorkerVersionPromise=void 0,this.detectLocale=()=>this.window.localStorage.getItem("localeCode")||this._migratedLocale&&oi(this._migratedLocale).locale||oi(this.window.navigator.language).locale,this.onlineHandler=()=>{this._networkState==="suspectedOffline"&&(this._networkState="unstable",this.cleanUpNetworkStateListener())},this.offlineHandler=()=>{this._networkState==="suspectedOnline"&&(this._networkState="unstable",this.cleanUpNetworkStateListener())},this._headConfig=Ei(t,n),this._bootType=this.getBootTypeInternal(),this.setInitConsoleLogLevel(),this.setUpNetworkStateListener(),this.readSettingsFromUrlHash(),this.setServiceWorkerVersion(),this.logger?.logNoPii(`Index with QSP: ${this.indexVersionQSP}`),this.setPlatformIdCookie()}}const dd=(e,t)=>{try{const r=Pa(t);if(r!==void 0)return r}catch(r){e.error(`Failed to get experience loader settings from local storage: ${r}`)}try{const r=document.head.getAttribute("data-config");return(r?JSON.parse(decodeURIComponent(r)):{}).experienceLoaderSettings||{}}catch(r){return e.error(`Failed to get experience loader settings from element: ${r}`),{}}},xa=(e,t)=>`tmp.${e}${t?".pwa":""}.experience-loader-ecs-flags`,Pa=e=>{const t=xa(globalThis.loaderConfig.experienceName,e),r=globalThis.localStorage.getItem(t);return r?JSON.parse(r):void 0},Ra=(e,t)=>{const r=xa(globalThis.loaderConfig.experienceName,t);globalThis.localStorage.setItem(r,JSON.stringify(e))},um=(e,t,r)=>{try{const n=Pa(r)||{},i=hd(n,e);return i.length>0?(Ra(e,r),i):[]}catch(n){return t.error(`SetExperienceLoaderSettings - Failed to get experience loader settings in local storage: ${n}`),Ra(e,r),Object.keys(e)}},fd=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):e===t,hd=(e,t)=>{const r=[];for(const n of Object.keys(e)){const i=e[n],o=t[n];!fd(i,o)&&!(i===!1&&o===void 0)&&r.push(n)}for(const n of Object.keys(t)){const i=e[n],o=t[n];i===void 0&&o!==void 0&&o!==!1&&r.push(n)}return r};function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ai={Created:"Created",CriticalError:"CriticalError",HostNotified:"HostNotified"};class pd{getLogsProvider(){return this.diagnosticsService}clearLoaderMarks(){this.telemetryService.clearLoaderMarks()}async execute(){try{if(await this.telemetryService.initialize(),zu(this.globalWindow,this.logger),this.clearStaleUpdatedSettingsKeys(),this.redirectToOcdi(),this.preLoadCacheStorage(),this.config.loadingScreenDelayInMs||this.setExpLoaderTimer(),this.logger.logNoPii(ai.HostNotified),this.diagnosticsService.setSessionId(this.telemetryService.sessionId||""),this.globalWindow?.performance?.mark("exp_loader_init"),this.telemetryService.addUxStatus("SplashScreenDisplayed"),this.uiManager.showLoadingScreen(),this.checkInput(),this.logger.logNoPii(`Loading build version: ${this.config.build}`),this.config.preInitWorker&&this.precoreWorkers.initPrecoreWorker(this.getProperties()),this.config.preInitSharedWorker&&this.precoreWorkers.initPrecoreSharedWorker(this.getProperties()),this.config.loadingScreenDelayInMs&&await pa(this.config.loadingScreenDelayInMs),this.globalWindow?.performance?.mark("show_loading_screen"),this.config?.manifest?.chunks&&this.config?.manifest?.chunks?.length>0)this.globalWindow.performance.mark(_.ConfigLoaded),this.loadingBundlesPromise=this.buildLoader.loadBuild(this.config.manifest),this.sendStepsToMaglev("exp_loader_steps_config_loaded"),await this.loadingBundlesPromise;else return this.globalWindow.performance.mark("exp_loader_err_manifest_chunks_empty"),this.showCriticalErrorScreen("ExpLoaderBuildDownloadFailure",new Error("Loader manifest is not valid"))}catch(t){return this.globalWindow.performance.mark("exp_loader_err_download_general_error"),this.sendStepsToMaglev("exp_loader_steps_general_error"),this.showCriticalErrorScreen("ExpLoaderBuildDownloadFailure",t)}try{this.diagnosticsService.persistDiagnostics(),this.globalWindow.performance.mark("exp_loader_before_core_init_start"),this.errorHappened?this.globalWindow.performance.mark("exp_loader_err_general_error_handler"):await this.waitForCoreInitStarted()}catch(t){return this.globalWindow.performance.mark("exp_loader_err_wait_for_core_init"),this.showCriticalErrorScreen("CoreInitBeginTimeout",t)}}async redirectToOcdi(){if(this.logger.logNoPii(`redirectToOcdi: entered. enableOCDIRedirects=${this.ecsSettings.enableOCDIRedirects}`),!this.ecsSettings.enableOCDIRedirects){this.logger.warnNoPii("OCDI redirect: Not redirecting - not enabled");return}const t=new URL(this.globalWindow.location.href),r=this.ecsSettings.ocdiRedirectCookieName||ms,n=this.ecsSettings.ocdiRedirectCookieAdditionalOptions||_s;if(t.searchParams.has(Mi)){this.globalWindow.document.cookie=`${r}=; expires=${vs}${n}`,this.logger.warnNoPii("OCDI redirect: Not redirecting - we arrived here due to a client redirect.");return}for(const d of this.ecsSettings.ocdiNoRedirectQSPs||[])if(t.searchParams.has(d)){this.logger.warnNoPii(`OCDI redirect: Not redirecting - URL contains '${d}', which is a no-redirect QSP`);return}if(!this.globalWindow.document.cookie.split("; ").find(d=>d.startsWith(`${r}=`))){this.logger.logNoPii("OCDI redirect: Not redirecting - cookie not set");return}const o=this.ecsSettings.ocdiRedirectPath||"";let s;try{s=new URL(o,this.ecsSettings.ocdiRedirectBaseUri)}catch{this.logger.errorNoPii(`OCDI redirect: Not redirecting - could not parse assigned URL. assignedBaseUri: ${this.ecsSettings.ocdiRedirectBaseUri}, assignedPath: ${o}`);return}if(t.hostname===s.hostname&&t.pathname===s.pathname){this.logger.warnNoPii("OCDI redirect: Not redirecting - already on assigned URL");return}this.logger.warnNoPii("OCDI redirect: Redirecting to assigned URL");const u=new URL(this.globalWindow.location.href);u.hostname=s.hostname,u.pathname=s.pathname,u.searchParams.set(Mi,"index"),this.globalWindow.location.replace(u.href)}async preLoadCacheStorage(){const t=["provider-cache-storage","teams-labs-service-cache-storage"];for(const r of t)try{await(await caches.open(r)).keys()}catch{this.logger.warnNoPii(`Failed to pre-load CacheStorage: ${r}`)}}openWindow(t,r,n){return this.windowManager.openWindowRequest(t,r,n)}getLoadingWindow(){return this.windowManager.getLoadingWindow()}getErrorWindow(){return this.windowManager.getWindow(Fr.Error)}getClientStartTelemetrySteps(){return this.telemetryService.getSuccessClientStartTelemetrySteps()}getProperties(){return{activeServiceWorkerVersion:this.platformService.activeServiceWorkerVersion,bootType:this.platformService.bootType,buildVersion:this.platformService.buildVersion,deeplinkId:this.platformService.deeplinkId,deeplinkTarget:this.platformService.deeplinkTarget,environment:this.platformService.environment,experienceName:this.config.experienceName,headConfig:this.platformService.headConfig,indexVersionQSP:this.platformService.indexVersionQSP,isMaglev:this.platformService.isMaglev,isPwa:this.platformService.isPwa,locale:this.platformService.locale,ring:this.platformService.ring,sessionId:this.telemetryService.sessionId,deviceId:this.telemetryService.deviceId,pdsEnvironment:this.platformService.pdsEnvironment,deviceInfo:this.telemetryService.deviceInfo,RelaunchReason:this.telemetryService.RelaunchReason,preAuthUserId:this.telemetryService.preAuthUserId,preCoreHostCommunication:this.hostCommunication,experienceLoaderSettings:this.ecsSettings,enableEarlyServiceWorkerRegistration:this.platformService.enableEarlyServiceWorkerRegistration,swCacheStatus:this.telemetryService.getSWCacheStatus()}}getInitConsoleLogLevel(){return{preECSConsoleLogLevel:this.platformService.preECSConsoleLogLevel,userConsoleLogLevel:this.platformService.userConsoleLogLevel}}getWorkerId(){return this.precoreWorkers.getWorkerId()}getWorker(){return this.precoreWorkers.getWorker()}getWorkerErrorBuffer(){return this.precoreWorkers.getWorkerErrorBuffer()}getSharedWorker(){return this.precoreWorkers.getSharedWorker()}getCdlWorkerUrl(){return this.precoreWorkers.getCdlWorkerUrl()}getCdlSharedWorkerUrl(){return this.precoreWorkers.getCdlSharedWorkerUrl()}getWorkerInitializationTime(){return this.precoreWorkers.getWorkerInitializationTime()}clearWorker(){this.precoreWorkers.clearWorker()}signalCoreInitStarted(){this.sendStepsToMaglev("exp_loader_steps_received_core_started"),this.logger.logNoPii("Received signal indicating core init started."),this.unregisterErrorHandlers(),this.waitForExpLoaderCompleteTimeout&&this.globalWindow.clearTimeout(this.waitForExpLoaderCompleteTimeout),this.waitForCoreInitStartTimeout&&this.globalWindow.clearTimeout(this.waitForCoreInitStartTimeout),this.coreInitStarted=!0,this.markIndexPageStop(),this.uiManager.hideErrorScreen(),this.resolveHandshakePromise&&(this.resolveHandshakePromise(),this.resolveHandshakePromise=void 0)}stopPieTimer(){this.waitForPieTimeout&&(this.logger.logNoPii("Stop the timer waiting for sending client_start events via PIE api."),this.globalWindow.clearTimeout(this.waitForPieTimeout),this.waitForPieTimeout=void 0,this.pieTimerStopped=!0,this.globalWindow.performance.mark("exp_loader_stop_pie_timer"),this.diagnosticsService.completeDiagnostics())}async onErrorHandler(t,r){this.unregisterErrorHandlers();let n=typeof t=="string"?t:[`Message: ${t?.message}`,`Filename: ${this.removeAllQSPandHash(t?.filename)}`,`Line: ${t?.lineno}`,`Column: ${t?.colno}`,`Error object: ${JSON.stringify(t?.error)}`].join(" - ");n=this.scrubQspEmailEuii(n)||"",this.globalWindow.performance.mark("exp_loader_err_global_window_error"),this.platformService.platformId===B.Web&&t?.message&&t.message.indexOf("Script error")>=0&&this.globalWindow.localStorage.setItem(qr,"true"),await this.handleGeneralError(n,t,r)}async flushTelemetry(){return this.loadingBundlesPromise?(await this.loadingBundlesPromise,!0):!1}persistLoaderLogsAsPreviousSession(){this.diagnosticsService?.persistDiagnosticsAsPreviousSessionLogs()}async checkClientStartFailureCount(){if(this.clientStartFailureCountChecked||!this.platformService.headConfig.enableUnregisterSWWhenClientStartFail)return;this.clientStartFailureCountChecked=!0,_u(this.globalWindow,this.config.experienceName,this.logger)&&(await ca(this.globalWindow,this.logger),mu(this.globalWindow),this.telemetryService.sendNewScenarioThroughONEDS(Gt.ClearSWForClientStartFailure,{Scenario_Status:"success"},"clear_sw_for_multiple_start_failure"))}clearStaleUpdatedSettingsKeys(){try{const t=this.globalWindow.localStorage,r=[];for(let n=0;n{this.coreInitStarted?(this.logger.logNoPii("Core initialization has started."),this.pieTimerStopped||this.waitForPie(),t()):(this.logger.logNoPii("Waiting for core init start."),this.resolveHandshakePromise=t,this.waitForCoreInitStartTimeout=this.globalWindow.setTimeout(()=>{const n=`Core init hasn't started within ${xi} ms.`;this.logger.warnNoPii(n),this.telemetryService.failClientStartScenarioWithMarks([],Ee.Timeout,{reason:n}),r(new Error(n))},xi),this.pieTimerStopped||this.waitForPie())})}waitForPie(){this.waitForPieTimeout=this.globalWindow.setTimeout(()=>{const t=`Core init hasn't finished within ${Pi} ms.`;this.logger.warnNoPii(t),this.telemetryService.failClientStartScenarioWithMarks([],Ee.Timeout,{reason:t})},Pi)}setExpLoaderTimer(){this.waitForExpLoaderCompleteTimeout=this.globalWindow.setTimeout(()=>this.expLoaderTimeoutHandler(),Ri)}expLoaderTimeoutHandler(){this.waitForCoreInitStartTimeout&&this.globalWindow.clearTimeout(this.waitForCoreInitStartTimeout),this.waitForPieTimeout&&(this.globalWindow.clearTimeout(this.waitForPieTimeout),this.pieTimerStopped=!0);const t=`ExpLoader hasn't finished within ${Ri} ms.`;this.logger.warnNoPii(t),this.showCriticalErrorScreen("ExpLoaderBuildDownloadTimeout",new Error(t))}isTrustedTypeError(t){return t?t.indexOf("TrustedScriptURL")>=0||t.indexOf("TrustedHTML")>=0||t.indexOf("TrustedScript")>=0:!1}registerErrorHandlers(){this.onErrorHandlerCallback=t=>t&&`${t.message}${t.filename}`.indexOf("-extension://")>=0?(this.logger.log("onErrorHandlerCallback: Error is from extension, skip handling"),!0):this.isTrustedTypeError(t?.message)?(this.logger.errorNoPii(`onErrorHandlerCallback: TrustedTypeError: ${t?.message}.`),!0):(this.onErrorHandler(t).catch(r=>{this.logger.errorNoPii(`onErrorHandlerCallback: Error handling error: ${r?.message}.`)}),!0),this.globalWindow.addEventListener("error",this.onErrorHandlerCallback),this.unhandledRejectionHandlerCallback=t=>{this.unhandledRejectionHandler(t).catch(r=>{this.logger.errorNoPii(`unhandledRejectionHandlerCallback: Error handling unhandled rejection: ${r?.message}.`)})},this.globalWindow.addEventListener("unhandledrejection",this.unhandledRejectionHandlerCallback)}async unhandledRejectionHandler(t){this.unregisterErrorHandlers();let r="";if(t?.reason){let n="";try{n=JSON.stringify(t.reason)}catch{}n&&n!=="{}"?r=n:typeof t.reason=="object"&&(r=`${t.reason.message??""} ${t.reason.stack??""}`.trim())}r=r||"ExpLoaderUnhandledRejection",await this.handleGeneralError(r,t)}async handleGeneralError(t,r,n){this.errorHappened=!0,this.loadingBundlesPromise&&await this.loadingBundlesPromise,this.logger?.errorNoPii(t,"webclient_framework_exp_loader_event");const i=await this.checkIsChunkLoadingErrorFromSWCache(t);await this.telemetryService.failClientStartScenarioWithMarks(void 0,Ee.Failure,{reason:t,errorCode:G.ExpLoaderFailure,isLoadedFromServiceWorkerCache:i}),this.showCriticalErrorScreen(n||"CoreInitUnhandledPromiseRejectionFailure",new Error(t)),n==="CoreInitFailure"&&await this.checkClientStartFailureCount(),r?.preventDefault?.()}async showCriticalErrorScreen(t,r){this.waitForExpLoaderCompleteTimeout&&this.globalWindow.clearTimeout(this.waitForExpLoaderCompleteTimeout),this.waitForCoreInitStartTimeout&&this.globalWindow.clearTimeout(this.waitForCoreInitStartTimeout),this.logger.errorNoPii(ai.CriticalError,r),await this.telemetryService.failClientStartScenarioWithMarks([],t==="ExpLoaderBuildDownloadTimeout"?Ee.Timeout:Ee.Failure,{reason:`Web critical error - ${r.message}`}),this.diagnosticsService?.persistDiagnosticsAsPreviousSessionLogs();const n=await this.loadCoreModule();if(n?.reportCriticalError)return n.reportCriticalError({type:t});let i;switch(t){case"ExpLoaderBuildDownloadFailure":case"ExpLoaderBuildDownloadTimeout":i=$t.loadingApp;break;case"CoreInitBeginTimeout":case"CoreInitFailure":case"CoreInitGlobalWindowErrorFailure":case"CoreInitUnhandledPromiseRejectionFailure":i=$t.coreInit;break}this.uiManager.showErrorScreen(i)}unregisterErrorHandlers(){this.onErrorHandlerCallback&&(this.globalWindow.removeEventListener("error",this.onErrorHandlerCallback),this.onErrorHandlerCallback=void 0),this.unhandledRejectionHandlerCallback&&(this.globalWindow.removeEventListener("unhandledrejection",this.unhandledRejectionHandlerCallback),this.unhandledRejectionHandlerCallback=void 0),this.platformService.cleanUpNetworkStateListener()}scrubQspEmailEuii(t){if(!t)return t;const r=new RegExp("=+[a-zA-Z0-9.!#$%&'*+\\/?^_`{|}~-]+(@|_(A|a)(T|t)_|%40)(?!(T|t)(H|h)(R|r)(E|e)(A|a)(D|d).(V|v)2)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*","g");let n=t;n=n.replace(r,"=email-euii");const i=new RegExp(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}/,"g");return n=n.replace(i,"=email-euii"),n}removeAllQSPandHash(t){if(!t)return t;try{const r=new URL(t);return r.search||r.hash?(r.search="",r.hash="",r.toString()):r.href}catch{const r=t.indexOf("?"),n=t.indexOf("#");let i=-1;return r>=0&&n>=0?i=r=0?i=r:n>=0&&(i=n),i===-1?t:t.substring(0,i)}}createHostCommunications(){if(this.globalWindow.nativeModules){const{Core:t,Osutils:r,Windowcontrols:n,Scenario:i,Telemetry:o,Hostcapabilities:s,Logscollection:l}=this.globalWindow.nativeModules;return{loadModule:async u=>{switch(u){case"core":return t;case"windowcontrols":return n;case"osutils":return r;case"scenario":return i;case"telemetry":return o;case"hostcapabilities":return s;case"logscollection":return l;default:return}}}}}async checkIsChunkLoadingErrorFromSWCache(t){let r="";try{if(t&&t.indexOf('"message":"Loading chunk')>=0){const n=JSON.parse(t.replace(/[\u0000-\u001F\u007F-\u009F]/g,""));n&&"request"in n&&n.request&&"name"in n&&n.name==="ChunkLoadError"&&(r=(await Qr(n.request,this.globalWindow)).toString())}}catch{this.logger.errorNoPii("Parsing IsChunkLoadingErrorFromSWCache fail.")}return r}async registerSW(){try{if(this.platformService.platformId!==B.Web||!this.platformService.enableEarlyServiceWorkerRegistration||!this.globalWindow.navigator.serviceWorker||this.globalWindow.navigator.serviceWorker.controller)return;const t=window.trustedTypes?.createPolicy("@msteams/frameworks-loader#register-service-worker-early",{createScriptURL:this.createSWURL.bind(this)});if(t){this.globalWindow.performance.mark(_.RegisterServiceWorker);const r=new URL("serviceworker.js",this.globalWindow.location.href).pathname,n="all",i=await this.globalWindow.navigator.serviceWorker.register(t.createScriptURL(r),{updateViaCache:n}),o=i.installing||i.waiting||i.active;o&&(this.globalWindow.performance.mark(_.TriggerSWCacheMainChunks),this.requestSWToPreCacheMainChunks(o))}else this.logger.warnNoPii("trustedScriptURl for sw is NOT created")}catch(t){this.logger.error(`sw registration fail in expLoader: ${t}`)}}createSWURL(t){const r=new URL(t,this.globalWindow.location.origin);if(r.origin===this.globalWindow.location.origin)return r;throw new Error(`invalid swURL: ${Fu(r.href)}`)}requestSWToPreCacheMainChunks(t){try{const r=this.getPreCacheChunkList();if(r&&r.length>0){const n=new MessageChannel;t.postMessage({message:"preCacheMainChunks",mainChunksArray:r},[n.port2])}this.globalWindow.localStorage.setItem(`${tn}${rn}`,Di)}catch{this.logger.error("Failed on triggering Service Worker preCacheMain chunks")}}getPreCacheChunkList(){const t=[];if(this.config?.manifest){const{asyncEntry:r,chunks:n,buildTimeConfigs:i}=this.config.manifest;if(i){const o=`config-${this.platformService.environment}`,s=i.filter(l=>l.path.indexOf(o)>=0);if(s.length>0){const l=s[0];t.push({url:l.path,integrity:l.integrity})}}if(n){r?.chunks?.length&&r.chunks.forEach(s=>t.push({url:s.path,integrity:s.integrity}));let o=n;this.platformService.enableSriForDynamicImports||(o=n.filter(s=>!s.isIntegritiesManifest)),o.forEach(s=>t.push({url:s.path,integrity:s.integrity}))}}return this.globalWindow.location.search||t.push({url:`${this.globalWindow.location.origin}${this.globalWindow.location.pathname}`}),t}constructor(t,r,n,i,o,s,l){U(this,"globalWindow",void 0),U(this,"config",void 0),U(this,"diagnosticsService",void 0),U(this,"logger",void 0),U(this,"platformService",void 0),U(this,"hostCommunication",void 0),U(this,"coreModule",void 0),U(this,"scenarioModule",void 0),U(this,"telemetryService",void 0),U(this,"windowManager",void 0),U(this,"uiManager",void 0),U(this,"buildLoader",void 0),U(this,"coreInitStarted",void 0),U(this,"pieTimerStopped",void 0),U(this,"errorHappened",void 0),U(this,"waitForCoreInitStartTimeout",void 0),U(this,"waitForPieTimeout",void 0),U(this,"waitForExpLoaderCompleteTimeout",void 0),U(this,"resolveHandshakePromise",void 0),U(this,"onErrorHandlerCallback",void 0),U(this,"unhandledRejectionHandlerCallback",void 0),U(this,"loadingBundlesPromise",void 0),U(this,"precoreWorkers",void 0),U(this,"ecsSettings",void 0),U(this,"clientStartFailureCountChecked",void 0),this.globalWindow=t,this.coreInitStarted=!1,this.pieTimerStopped=!1,this.errorHappened=!1,this.clientStartFailureCountChecked=!1,this.config=Object.assign(jo,r),this.diagnosticsService=new Qu(t,this.config),this.logger=this.diagnosticsService.newLogger("ExperienceLoader"),this.loadConfigOverrides(),this.platformService=new ud(t,this.config,this.logger),this.platformService.isMaglev&&(this.hostCommunication=this.createHostCommunications()),this.telemetryService=i(t,this.diagnosticsService,this.platformService,this.hostCommunication,this.config),this.windowManager=o(t,this.config,n,this.diagnosticsService,this.platformService,this.hostCommunication),this.ecsSettings=dd(this.logger,this.platformService.isPwa),this.uiManager=s(this.diagnosticsService,this.windowManager,this.platformService,this.telemetryService,this.hostCommunication),this.buildLoader=l(t,this.diagnosticsService,this.telemetryService,this.diagnosticsService,this.platformService),this.precoreWorkers=new Yu(this.globalWindow,this.config,this.platformService,this.logger,this.ecsSettings),this.registerErrorHandlers(),this.logger.logNoPii(ai.Created),this.registerSW()}}async function gd(e){try{console.log("[ExpLoader] Getting things ready...");const t=window;await md(t);const r=new pd(t,t.loaderConfig,e,Mu,Du,Nu,Uu);t.loader=r,await r.execute()}catch(t){throw console.error("[ExpLoader] Unhandled Exception:",t),t}}async function md(e){try{if(Li(e)&&"nativeModules"in e){e.performance.mark(_.NotifyDesktop);const t=e.nativeModules;t?.Core?.notifyLoaderStarted&&(await t.Core.notifyLoaderStarted(),console.log("[ExpLoader] notify loader started signal sent to desktop"))}}catch(t){console.error("[ExpLoader] notify loader started fail:",t)}}function _d(e){var t,r="",n=Array.prototype.join;function i(){r+=n.call(arguments,"")}return r+=`
`,e.titleBar&&(r+=`
`),r+=`
Loading...
`,r}function vd(e){var t,r="";return r+=``,r}function yd(e){var t,r="";return r+=``,r}function wd(e){var t,r="",n=Array.prototype.join;function i(){r+=n.call(arguments,"")}return r+=`
`,osPlatform==="windows"&&(r+=`
`),r+=`
`,r}function bd(e){var t,r="",n=Array.prototype.join;function i(){r+=n.call(arguments,"")}return r}const Sd={splashStyles:vd,favicons:yd,splash:_d,preloadTitleBar:wd,devtools:bd};function Cd(e){var t,r="",n=Array.prototype.join;function i(){r+=n.call(arguments,"")}r+=` `,e.htmlWebpackPlugin.options.isMainWindow&&(r+=`