(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{1505:function(e,o,n){"use strict";n.r(o),n.d(o,"loadApp",(function(){return b}));var t=n(78),i=n.n(t),a=n(89),r=n(112),s=n(80),l=n(261),c=n(237),d=n(271),u=n(90),g=n(19),f=n(138);window.React=i.a;let w=null;function h(e){const o=Object(g.b)(e);return{screen:o.location.substring(1),params:o.params}}function p(e){decodeURIComponent(window.location.hash)!==w&&function(e){if(!window.matrixChat)return;console.log("Routing URL ",e.href);const o=h(e);window.matrixChat.showScreen(o.screen,o.params)}(window.location)}function _(e,o=!1){console.log("newscreen "+e);const n="#/"+e;w=n,e.startsWith("room/")&&window.location.hash.includes("/$")===n.includes("/$")&&window.location.hash.startsWith(n)&&(o=!0),o?window.location.replace(n):window.location.assign(n)}function m(e){let o;o="vector:"===window.location.protocol?"https://app.element.io/#/register":window.location.protocol+"//"+window.location.host+window.location.pathname+"#/register";const n=Object.keys(e);for(let t=0;t<n.length;++t){o+=0===t?"?":"&";const i=n[t];o+=i+"="+encodeURIComponent(e[i])}return o}function v(){const e=new URL(window.location.href);e.searchParams.delete("loginToken"),console.log(`Redirecting to ${e.href} to drop loginToken from queryparams`),window.history.replaceState(null,"",e.href)}async function b(e){window.addEventListener("hashchange",p);const o=r.a.get(),n=Object(g.a)(window.location),t=window.location.protocol+"//"+window.location.host+window.location.pathname;console.log("Vector starting at "+t),o.startUpdater();const w=await async function(){let e;try{console.log("Verifying homeserver configuration");const o=u.a.get();let n=o.default_server_config;const t=o.default_server_name,i=o.default_hs_url,a=o.default_is_url,r=[n,t,i].filter(e=>!!e);if(r.length>1)throw Object(s.h)(Object(s.b)("Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url."));if(r.length<1)throw Object(s.h)(Object(s.b)("Invalid configuration: no default server specified."));i&&(console.log("Config uses a default_hs_url - constructing a default_server_config using this information"),console.warn("DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use default_server_config instead."),n={"m.homeserver":{base_url:i}},a&&(n["m.identity_server"]={base_url:a}));let d=null;n&&(console.log("Config uses a default_server_config - validating object"),d=await c.a.fromDiscoveryConfig(n)),t&&(console.log("Config uses a default_server_name - doing .well-known lookup"),console.warn("DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please use default_server_config instead."),d=await c.a.findClientConfig(t)),e=l.a.buildValidatedConfigFromDiscovery(t,d,!0)}catch(o){const{hsUrl:n,isUrl:t,userId:i}=await d.c();if(!n||!i)throw o;console.error(o),console.warn("A session was found - suppressing config error and using the session's homeserver"),console.log("Using pre-existing hsUrl and isUrl: ",{hsUrl:n,isUrl:t}),e=await l.a.validateServerConfigWithStaticUrls(n,t,!0)}return e.isDefault=!0,console.log("Using homeserver config:",e),console.log("Updating SdkConfig with validated discovery information"),u.a.add({validated_server_config:e}),u.a.get()}(),[b]=await d.b(),C=!!b,U=!!n.loginToken,y=!0===w.sso_immediate_redirect;if(!C&&!U&&y){console.log("Bypassing app load to redirect to SSO");const e=Object(f.createClient)({baseUrl:w.validated_server_config.hsUrl,idBaseUrl:w.validated_server_config.isUrl});return void r.a.get().startSingleSignOn(e,"sso","/"+h(window.location).screen)}const O=a.getComponent("structures.MatrixChat");return i.a.createElement(O,{onNewScreen:_,makeRegistrationUrl:m,config:w,realQueryParams:n,startingFragmentQueryParams:e,enableGuest:!w.disable_guests,onTokenLoginCompleted:v,initialScreenAfterLogin:h(window.location),defaultDeviceDisplayName:o.getDefaultDeviceDisplayName()})}console.log("Application is running in production mode")}}]);
//# sourceMappingURL=element-web-app.js.map