@arcgis/portal-components 5.2.0-next.62 → 5.2.0-next.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as T}from"./YVKSTDL6.js";import c from"./G2KWSRCG.js";import a from"./DALGPO36.js";import"./VMQIDO4Z.js";import"./QS3GXAIH.js";import{b as C}from"./2GBRZSEC.js";import{a as L}from"./44XITKIX.js";import{a as M}from"./7ZXEX3LI.js";import"./SKUPHVNO.js";import"./TNLGQ7HL.js";import{M as S,P as _,S as v,j as d,k as b,w as f}from"./TSTTPCWU.js";import"./UZLQALHY.js";export default $arcgis.t(([p,{substitute:g},,{i:x,j:O,k:E,l:I}])=>{var A=1260*1e3;function K(n,e="_blank",t=582,s=670){let i=window.screenLeft??0,r=window.screenTop??0,o=window.innerWidth||document.documentElement.clientWidth||window.screen.width,a=window.innerHeight||document.documentElement.clientHeight||window.screen.height,c=o/2-t/2+i,u=a/2-s/2+r,l=window.open(n,e,`scrollbars=no, width=${t}, height=${s}, top=${u}, left=${c}`);return l?.focus(),l}function J(n){let e=(n||window.location.origin).split(".")[1].replace("maps","");return`https://${e?`${e}${e==="qa"?"ext":""}.`:""}arcgis.com/sharing/rest/`}function P(n,e){let t=p.findOAuthInfo(n.url),{locale:s="en",expiration:i=A}=t??{},r=new URLSearchParams({locale:s,client_id:"arcgisonline",response_type:"token",expiration:`${i}`,linkUserRequest:"true",showSocialLogins:"true",hideEnterpriseLogins:"false",force_login:"true",parent:window.location.origin,redirect_uri:`https://${n.portalHostname}/home/link_account_callback.html`,state:JSON.stringify({useMessage:!0})}),o=`${J(e)}oauth2/authorize?${r.toString()}`;K(o)}function H(n){let{config:e,credential:t,clientId:s="arcgisonline",redirectToClientUri:i=!1,displaySignoutComplete:r=!1}=n,o=new URLSearchParams({display:"iframe",client_id:s,...t.token&&{token:t.token},parent:window.location.origin,redirect_uri:`${e.baseUrl}signout_callback.html`,state:JSON.stringify({signout:!0,origin:window.location.origin,redirectToClientUri:i,displaySignoutComplete:r})}),a=`${e.restBaseUrl}oauth2/signout?${o.toString()}`,c=document.createElement("iframe");c.src=a,c.style.display="none",document.body.appendChild(c)}function R(n,e){let t=h(n.orgUrlKey,e),s=p.findOAuthInfo(t),{locale:i="en",expiration:r=A}=s??{},o=y(n.provider),a=new URLSearchParams({locale:i,client_id:"arcgisonline",response_type:"token",expiration:`${r}`,parent:window.location.origin,...o==="social"&&{socialLoginProviderName:n.provider},...o==="default"&&{prepopulatedusername:n.username},force_login:"true",redirect_uri:`${t}/home/sign_in_callback.html`,state:JSON.stringify({user:n.username,server:t,portalUrl:t,origin:window.location.origin})}),c=`${U(n,e)}?${a.toString()}`;K(c)}function B({account:n,credential:e,portal:t}){let s=y(n.provider),i=U(n,t),r=N(n,t),o=new URLSearchParams({client_id:"arcgisonline",redirect_uri:r,parent:window.location.origin,response_type:"token",force_login:"false",...e.userId&&{prepopulatedusername:e.userId},...s==="social"&&{socialLoginProviderName:n.provider},expiration:`${(e?.expires??Date.now()+A)-Date.now()}`});return`${i}?${o.toString()}`}function y(n){return D(n)?"social":n==="enterprise"?"enterprise":n.includes("oidc")?"oidc":"default"}function D(n){return["apple","facebook","github","google"].includes(n)}function U(n,e){let t=h(n.orgUrlKey,e).toLowerCase(),s=y(n.provider),i="";switch(s){case"social":i="social/";break;case"enterprise":i="saml/";break;case"oidc":i=`oidc/${n.provider.split("_")[1]}/`;break}return`${t}/sharing/rest/oauth2/${i}authorize`}function h(n,e){return n?.startsWith("https://")?n:n&&e.customBaseUrl?`https://${n}.${e.customBaseUrl}`:`https://${e.portalHostname}`}function N(n,e){return`${h(n.orgUrlKey,e)}/home/accountswitcher-callback.html`}function q({origin:n,redirectToClientUri:e,displaySignoutComplete:t}){console.log("Signout complete",n,e,t)}function z(n,e){return p.findCredential(h(n.orgUrlKey,e),n.username)}function j(n,e){let t=z(n,e);if(t)return t;let s=h(n.orgUrlKey,e),i=`${s}/home/check_sign_in_status.html#state=${JSON.stringify({origin:window.location.origin,server:s,orgKey:s})}`;G(i,`iframe__for-${s}`)}function G(n,e){let t=document.createElement("iframe");t.src=n,t.id=e,t.style.display="none",document.body.appendChild(t)}var w=100,$=class extends S{constructor(){super(),this.messages=M({blocking:!0}),this.clientId="arcgisonline",this.targetUser="",this.targetToken="",this.baseUrl="",this.linkedAccounts=[],this.loading=!1,this.signedInStatus={},this.showAssociatedAccountsWarning=!1,this.arcgisAccountSwitch=f(),this.arcgisClose=f(),this.listenOn(window,"message",this.handleMessageEvent)}static{this.properties={linkedAccounts:16,userAccounts:16,user:16,credential:16,alertOptions:16,loading:16,signedInStatus:16,showAssociatedAccountsWarning:16,portal:0}}static{this.styles=L}connectedCallback(){super.connectedCallback(),this.baseUrl=h(this.portal?.urlKey??"",this.portal)}willUpdate(e){e.has("portal")&&(this.user=this.portal?.user),(e.has("portal")||e.has("user"))&&this.portal&&this.user&&this.findLinkedUsers()}handleMessageEvent(e){if(new URL(e.origin).hostname!=="localhost"&&(e.origin.endsWith(".arcgis.com")||e.origin===window.location.origin)){if(typeof e.data=="string"){JSON.parse(e.data).type==="token_exchange"&&this.handleExchangeTokenMessage(e);return}if("type"in e.data)switch(e.data.type){case"signin":this.handleSigninMessage(e);return;case"signout":this.handleSignoutMessage(e);return;case"linkUser":this.handleLinkUserMessage(e);return;case"token_exchange":this.handleExchangeTokenMessage(e);return}if("credential"in e.data){this.handleSigninMessage(e);return}this.handleCheckSignInStatusMessage(e)}}handleSignoutMessage(e){let{error:t,signout:s,accountOrigin:i,redirectToClientUri:r,displaySignoutComplete:o}=e.data;if(t&&t!=="unknown"){console.error(t),reportError(this.messages.errors.signout);return}s&&(this.user=void 0,this.credential=void 0,q({origin:i,redirectToClientUri:r,displaySignoutComplete:o}))}handleSigninMessage(e){let{messages:t}=this,{error:s,status:i,state:r,access_token:o,ssl:a}=e.data;if(s){console.error(s),reportError(t.errors.signin);return}if(i==="success"){let{portal:c,user:u}=this,l=this.linkedAccounts.find(W=>W.username===r.user);l?.orgUrlKey===this.portal.urlKey&&p.findCredential(`https://${c.portalHostname}`,u?.username)?.destroy();let m={server:r.portalUrl,userId:r.user,token:o,expires:Number(e.data.expires_in)+Date.now(),ssl:a===void 0||a!=="false"};p.registerToken(m);let k=B({account:l,credential:m,portal:c});window.self!==window.top?window.top?.postMessage({type:"navigate",url:k}):window.location.href=k}}handleCheckSignInStatusMessage(e){let{success:t,orgKey:s,server:i,userId:r,token:o,expires:a,ssl:c}=e.data;s&&i&&t&&r&&o&&a&&c!==void 0&&(this.signedInStatus[r]={token:o,expires:a,ssl:c})}async handleLinkUserMessage(e){let{error:t,username:s,access_token:i}=e.data,{portal:r,user:o,linkedAccounts:a,messages:c}=this;if(t){if(t.toString().toLowerCase().includes("user denied your request"))return;reportError(c.errors.accessAccount);return}if(s===o?.username){reportError(c.errors.selfLink);return}if(a.find(l=>l.username===s)){reportError(g(c.errors.alreadyLinked,{username:s}));return}let u=await O(r,s,i);if(u?.length){this.userAccounts=u,this.targetUser=s??"",this.targetToken=i??"",this.showAssociatedAccountsWarning=!0;return}this.linkAccount(s,i)}handleExchangeTokenMessage(e){let t=typeof e.data=="string"?JSON.parse(e.data):e.data;if(!(t.type&&t.type!=="token_exchange")){if(t.error)console.error(t);else if(t.status==="success"&&this.targetUser){let{portal:s,linkedAccounts:i,targetUser:r,clientId:o}=this,a=i.find(k=>k.username===r);if(!a)return;let c=N(a,s),u=h(a.orgUrlKey,s),l=new URLSearchParams({response_type:"token",client_id:o,redirect_uri:c,state:JSON.stringify({user:a.username,portalUrl:u})}),m=`${U(a,s)}?${l.toString()}`;window.opener?(window.opener.location.href=m,window.close()):window.location.href=m}}}async findLinkedUsers(){if(!this.portal||!this.user){this.linkedAccounts=[];return}this.loading=!0,this.linkedAccounts=await x(this.portal,this.user),this.linkedAccounts.length&&(this.signedInStatus=this.linkedAccounts.filter(e=>e.orgUrlKey!==this.portal.urlKey).reduce((e,t)=>(e[t.username]=j(t,this.portal)??null,e),{})),this.loading=!1}async linkAccount(e,t){let{portal:s,user:i}=this;if(!s||!i)return;let r=await E({portal:s,user:i,targetUser:e,targetToken:t}),{messages:o}=this;if(r.error){this.reportError(g(o.errors.linkAccount,{username:e})),this.targetUser="",this.userAccounts=[];return}let a=this.userAccounts?.length?o.success.linkAccountMultiple:o.success.linkAccount;this.reportSuccess(g(a,{username:e})),this.targetUser="",this.userAccounts=[],await C(350),this.findLinkedUsers()}async unlinkAccount(e){if(!this.portal||!this.user)return;let{messages:t,portal:s,user:i}=this,{success:r}=await I({portal:s,user:i,linkedUsername:e.username});r?this.reportSuccess(g(t.success.unlinkAccount,{username:e.username})):this.reportError(g(t.errors.unlinkAccount,{username:e.username})),await this.findLinkedUsers()}startAccountLink(){P(this.portal,this.baseUrl)}switchAccount(e){let{portal:t,user:s,clientId:i}=this;if(!t||!s||!e)return;let r=h(s.sourceJSON.orgUrlKey??"",t),o=p.findCredential(r,s.id||s.username);o&&H({config:{baseUrl:r,restBaseUrl:`${r}/sharing/rest`},credential:o,clientId:i}),R(e,t)}reportError(e,t,s=!1){this.alertOptions={kind:s?"warning":"danger",title:t,message:e}}reportSuccess(e,t){this.alertOptions={kind:"success",title:t,message:e}}showUnlinkConfirmation(e){let{messages:t}=this;this.alertOptions={kind:"danger",icon:"exclamation-mark-triangle-f",title:t.unlinkTitle,message:t.unlinkWarning,actions:[{text:t.unlink,kind:"danger",clickHandler:()=>{this.alertOptions=void 0,this.unlinkAccount(e)}}]}}render(){let{linkedAccounts:e,user:t,portal:s,messages:i}=this;return!s||!t?null:d`<calcite-dialog .heading=${i.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${()=>{this.arcgisClose.emit()}}><calcite-block .heading=${i.currentAccount} expanded class="current-account-block"><calcite-list .label=${g(i.currentAccountLabel,{username:t.username})} interaction-mode=static selection-mode=none class="current-account-list"><calcite-list-item><arcgis-portal-user-avatar .user=${t} .portal=${s} show-name .heading=${t.username} .description=${s.name||""} slot=content-start></arcgis-portal-user-avatar></calcite-list-item></calcite-list></calcite-block>${e.length>0?d`<calcite-block .heading=${i.chooseAccount} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${()=>this.startAccountLink()} .disabled=${e.length>=w}>${i.linkAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${s} .linkedAccounts=${e} .signedInUsers=${Object.keys(this.signedInStatus).filter(r=>this.signedInStatus[r]!==null)} .label=${i.usersList} interactive @arcgisAccountSwitch=${r=>{this.switchAccount(r.detail.account)}} @arcgisAccountUnlink=${r=>{this.showUnlinkConfirmation(r.detail.account)}}></arcgis-portal-account-switcher-list></calcite-block>`:d`<calcite-block .heading=${i.chooseAccount} expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${b`<path d=${T.couple??_} fill=currentColor />`}</svg><h4>${i.emptyListTitle}</h4><p>${i.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${()=>this.startAccountLink()} .disabled=${e.length>=w}>${i.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${e.length>=w}><div slot=message>${i.maxAccounts}</div></calcite-notice><calcite-alert .label=${i.alertLabel} slot=alerts .autoClose=${this.alertOptions?.kind!=="danger"} auto-close-duration=fast placement=bottom .kind=${this.alertOptions?.kind} .icon=${this.alertOptions?.icon} .open=${!!this.alertOptions} @calciteAlertClose=${()=>{this.alertOptions=void 0}}>${this.alertOptions?.title&&d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>`||""}${this.alertOptions?.message&&d`<p slot=message class="alert-message">${this.alertOptions.message}</p>`||""}${this.alertOptions?.actions?.map(r=>d`<calcite-button slot=actions-end .kind=${r.kind} .appearance=${r.appearance} @click=${r.clickHandler}>${r.text}</calcite-button>`)}</calcite-alert></calcite-dialog>${this.showAssociatedAccountsWarning&&d`<arcgis-portal-account-switcher-accounts .portal=${s} .targetUser=${this.targetUser} .accounts=${this.userAccounts??[]} @arcgisLinkAll=${()=>{this.linkAccount(this.targetUser,this.targetToken)}} @arcgisCloseDialog=${()=>{this.showAssociatedAccountsWarning=!1}}></arcgis-portal-account-switcher-accounts>`||""}`}};v("arcgis-portal-account-switcher",$);return $},"identity/IdentityManager","intl",a,c)