@arcgis/portal-components 5.2.0-next.86 → 5.2.0-next.87

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.
Files changed (68) hide show
  1. package/dist/cdn/{GADH24KO.js → 25KISBCS.js} +1 -1
  2. package/dist/cdn/2TQ4B2LU.js +2 -0
  3. package/dist/cdn/4GRTJ7XT.js +2 -0
  4. package/dist/cdn/{ZAB6B2B6.js → 5EMPEJ65.js} +1 -1
  5. package/dist/cdn/C7XKSVMU.js +2 -0
  6. package/dist/cdn/{DHWAQSKG.js → F3LFFR3K.js} +1 -1
  7. package/dist/cdn/F3M3R7X2.js +2 -0
  8. package/dist/cdn/{CD2GV5YW.js → F76RXJ66.js} +1 -1
  9. package/dist/cdn/FQTFZLHT.js +2 -0
  10. package/dist/cdn/KYNL256E.js +2 -0
  11. package/dist/cdn/{NASFEWDT.js → LDYOCDG6.js} +1 -1
  12. package/dist/cdn/{LRADZ46B.js → NQQLTGIK.js} +1 -1
  13. package/dist/cdn/{R5MGNFM2.js → PMQCCLS5.js} +1 -1
  14. package/dist/cdn/QTKBB22S.js +2 -0
  15. package/dist/cdn/SYDYG3CL.js +2 -0
  16. package/dist/cdn/{TUBYAQ6R.js → X5B4PAML.js} +1 -1
  17. package/dist/cdn/{ECA5GSSU.js → X6XTK2TE.js} +1 -1
  18. package/dist/cdn/{6BALICUQ.js → Y56BS6IQ.js} +52 -52
  19. package/dist/cdn/YBWCEZJP.js +2 -0
  20. package/dist/cdn/assets/portal-account-switcher/t9n/messages.en.json +1 -1
  21. package/dist/cdn/index.js +1 -1
  22. package/dist/chunks/fieldAddDelete.js +1 -1
  23. package/dist/chunks/groups2.js +1 -1
  24. package/dist/chunks/item2.js +1 -1
  25. package/dist/chunks/portal-account-switcher.js +3 -3
  26. package/dist/chunks/portal.js +2 -2
  27. package/dist/chunks/portal2.js +1 -1
  28. package/dist/chunks/request.js +1 -1
  29. package/dist/chunks/services.js +17 -0
  30. package/dist/chunks/user.js +1 -1
  31. package/dist/chunks/utils.js +4 -4
  32. package/dist/components/arcgis-portal-account-switcher/customElement.d.ts +22 -2
  33. package/dist/components/arcgis-portal-account-switcher/customElement.js +211 -207
  34. package/dist/components/arcgis-portal-account-switcher/index.js +1 -3
  35. package/dist/components/arcgis-portal-account-switcher/types.d.ts +6 -0
  36. package/dist/components/arcgis-portal-account-switcher-accounts/customElement.d.ts +20 -2
  37. package/dist/components/arcgis-portal-account-switcher-accounts/customElement.js +5 -5
  38. package/dist/components/arcgis-portal-account-switcher-list/customElement.d.ts +22 -4
  39. package/dist/components/arcgis-portal-account-switcher-list/customElement.js +58 -37
  40. package/dist/components/arcgis-portal-account-switcher-list/index.js +2 -3
  41. package/dist/components/arcgis-portal-ai-assistant/agents/portalRouteKeys.d.ts +25 -16
  42. package/dist/components/arcgis-portal-ai-assistant/agents/types.d.ts +4 -4
  43. package/dist/components/arcgis-portal-ai-assistant/customElement.js +611 -603
  44. package/dist/components/arcgis-portal-field-delete/customElement.js +1 -1
  45. package/dist/components/arcgis-portal-group-browser/customElement.js +1 -1
  46. package/dist/components/arcgis-portal-group-thumbnail/customElement.js +1 -1
  47. package/dist/components/arcgis-portal-navigation/customElement.js +1 -2
  48. package/dist/components/arcgis-portal-user-avatar/customElement.js +25 -36
  49. package/dist/components/arcgis-portal-user-popup/customElement.js +27 -27
  50. package/dist/docs/api.json +1 -1
  51. package/dist/docs/docs.json +1 -1
  52. package/dist/docs/vscode.html-custom-data.json +1 -1
  53. package/dist/docs/web-types.json +1 -1
  54. package/dist/loader.js +4 -4
  55. package/dist/types/lumina.d.ts +2 -2
  56. package/dist/types/preact.d.ts +2 -2
  57. package/dist/types/react.d.ts +2 -2
  58. package/dist/types/stencil.d.ts +2 -2
  59. package/dist/types/user.d.ts +1 -1
  60. package/package.json +7 -7
  61. package/dist/cdn/5MVBQWW3.js +0 -2
  62. package/dist/cdn/76A6NXMY.js +0 -2
  63. package/dist/cdn/E4D3U6ZA.js +0 -2
  64. package/dist/cdn/J57ZXL3U.js +0 -2
  65. package/dist/cdn/OAKVCMNN.js +0 -2
  66. package/dist/cdn/QREMLELA.js +0 -2
  67. package/dist/cdn/SOJ5KMMZ.js +0 -2
  68. package/dist/cdn/V6N5BWDA.js +0 -2
@@ -1,284 +1,288 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import { c as L } from "../../chunks/runtime.js";
3
- import { LitElement as _, createEvent as y, nothing as O } from "@arcgis/lumina";
4
- import { html as d, svg as I } from "lit";
5
- import { s as x } from "../../chunks/portal-account-switcher.js";
6
- import { g as C, a as v, l as T, u as M } from "../../chunks/user.js";
7
- import p from "@arcgis/core/identity/IdentityManager.js";
3
+ import { keyed as _ } from "lit/directives/keyed.js";
4
+ import { LitElement as O, createEvent as b, nothing as v } from "@arcgis/lumina";
5
+ import { html as d, svg as x } from "lit";
6
+ import { s as C } from "../../chunks/portal-account-switcher.js";
7
+ import { g as T, a as M, l as K, u as N } from "../../chunks/user.js";
8
+ import g from "@arcgis/core/identity/IdentityManager.js";
8
9
  import { t as E } from "../../chunks/functionalities.js";
9
- import { u as K } from "../../chunks/useT9n.js";
10
- import { m as P } from "../../chunks/icons.js";
11
- import { substitute as g } from "@arcgis/core/intl.js";
10
+ import { u as P } from "../../chunks/useT9n.js";
11
+ import { m as W } from "../../chunks/icons.js";
12
+ import { substitute as m } from "@arcgis/core/intl.js";
13
+ import { g as H } from "../../chunks/services.js";
12
14
  const w = 1260 * 1e3;
13
- function S(i, t = "_blank", e = 582, s = 670) {
14
- const n = 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 - e / 2 + n, u = a / 2 - s / 2 + r, l = window.open(i, t, `scrollbars=no, width=${e}, height=${s}, top=${u}, left=${c}`);
15
- return l?.focus(), l;
15
+ function S(n, e = "_blank", s = 582, t = 670) {
16
+ const i = window.screenLeft ?? 0, o = window.screenTop ?? 0, r = window.innerWidth || document.documentElement.clientWidth || window.screen.width, a = window.innerHeight || document.documentElement.clientHeight || window.screen.height, c = r / 2 - s / 2 + i, l = a / 2 - t / 2 + o, u = window.open(n, e, `scrollbars=no, width=${s}, height=${t}, top=${l}, left=${c}`);
17
+ return u?.focus(), u;
16
18
  }
17
- function W(i) {
18
- const t = p.findOAuthInfo(i.url), {
19
- /* appId = "arcgisonline", */
20
- locale: e = "en",
21
- expiration: s = w
22
- } = t ?? {}, n = new URLSearchParams({
23
- locale: e,
24
- client_id: "arcgisonline",
25
- //appId!,
19
+ function R(n, e) {
20
+ const s = g.findOAuthInfo(n.url), { appId: t, locale: i = "en", expiration: o = w } = s ?? {}, r = new URLSearchParams({
21
+ locale: i,
22
+ client_id: e ?? t ?? "arcgisonline",
26
23
  response_type: "token",
27
- expiration: `${s}`,
24
+ expiration: `${o}`,
28
25
  linkUserRequest: "true",
29
26
  showSocialLogins: "true",
30
27
  hideEnterpriseLogins: "false",
31
28
  force_login: "true",
32
29
  parent: window.location.origin,
33
- redirect_uri: `https://${i.portalHostname}/home/link_account_callback.html`,
30
+ redirect_uri: `https://${n.portalHostname}/home/link_account_callback.html`,
34
31
  state: JSON.stringify({ useMessage: !0 })
35
- }), r = `https://${i.portalHostname}/sharing/oauth2/authorize?${n.toString()}`;
36
- S(r);
32
+ }), a = `https://${n.portalHostname}/sharing/oauth2/authorize?${r.toString()}`;
33
+ S(a);
37
34
  }
38
- function N(i) {
35
+ function B(n) {
39
36
  const {
40
- config: t,
41
- credential: e,
42
- clientId: s = "arcgisonline",
43
- redirectToClientUri: n = !1,
44
- displaySignoutComplete: r = !1
45
- } = i, o = new URLSearchParams({
37
+ config: e,
38
+ credential: s,
39
+ clientId: t = "arcgisonline",
40
+ redirectToClientUri: i = !1,
41
+ displaySignoutComplete: o = !1
42
+ } = n, r = new URLSearchParams({
46
43
  display: "iframe",
47
- client_id: s,
48
- ...e.token && { token: e.token },
44
+ client_id: t,
45
+ ...s.token && { token: s.token },
49
46
  parent: window.location.origin,
50
- redirect_uri: `${t.baseUrl}signout_callback.html`,
47
+ redirect_uri: `${e.baseUrl}signout_callback.html`,
51
48
  state: JSON.stringify({
52
49
  signout: !0,
53
50
  origin: window.location.origin,
54
- redirectToClientUri: n,
55
- displaySignoutComplete: r
51
+ redirectToClientUri: i,
52
+ displaySignoutComplete: o
56
53
  })
57
- }), a = `${t.restBaseUrl}oauth2/signout?${o.toString()}`, c = document.createElement("iframe");
54
+ }), a = `${e.restBaseUrl}oauth2/signout?${r.toString()}`, c = document.createElement("iframe");
58
55
  c.src = a, c.style.display = "none", document.body.appendChild(c);
59
56
  }
60
- function H(i, t) {
61
- const e = h(i.orgUrlKey, t), s = p.findOAuthInfo(e), {
62
- /* appId = "arcgisonline", */
63
- locale: n = "en",
64
- expiration: r = w
65
- } = s ?? {}, o = $(i.provider), a = new URLSearchParams({
66
- locale: n,
67
- client_id: "arcgisonline",
68
- //appId,
57
+ function J(n, e, s) {
58
+ const t = h(n.orgUrlKey, e), i = g.findOAuthInfo(t), { appId: o, locale: r = "en", expiration: a = w } = i ?? {}, c = $(n.provider), l = new URLSearchParams({
59
+ locale: r,
60
+ client_id: s ?? o ?? "arcgisonline",
69
61
  response_type: "token",
70
- expiration: `${r}`,
62
+ expiration: `${a}`,
71
63
  parent: window.location.origin,
72
- ...o === "social" && { socialLoginProviderName: i.provider },
73
- ...o === "default" && { prepopulatedusername: i.username },
64
+ ...c === "social" && { socialLoginProviderName: n.provider },
65
+ ...c === "default" && { prepopulatedusername: n.username },
74
66
  force_login: "true",
75
- redirect_uri: `${e}/home/sign_in_callback.html`,
67
+ redirect_uri: `${t}/home/sign_in_callback.html`,
76
68
  state: JSON.stringify({
77
- user: i.username,
78
- server: e,
79
- portalUrl: e,
69
+ user: n.username,
70
+ server: t,
71
+ portalUrl: t,
80
72
  origin: window.location.origin
81
73
  })
82
- }), c = `${A(i, t)}?${a.toString()}`;
83
- S(c);
74
+ }), u = `${A(n, e)}?${l.toString()}`;
75
+ S(u);
76
+ }
77
+ function D({
78
+ accounts: n,
79
+ clientId: e = "arcgisonline",
80
+ usersToFilter: s = [],
81
+ accountsToFilter: t = ""
82
+ }) {
83
+ const i = {};
84
+ return n.reduce((o, r) => {
85
+ const a = {
86
+ disabled: r.disabled ?? !1,
87
+ allowed: r.clientAppAccessAllowed ?? !0
88
+ };
89
+ return o[r.username] = a, (s.includes(r.username) || s.includes(r.username.toLowerCase()) || t === "org" && r.orgUrlKey || e === "esriapps" && r.userType !== "both") && (a.allowed = !1), o;
90
+ }, i), i;
84
91
  }
85
- function B({
86
- account: i,
87
- credential: t,
88
- //client_id,
89
- portal: e
92
+ function j({
93
+ account: n,
94
+ credential: e,
95
+ client_id: s,
96
+ portal: t
90
97
  }) {
91
- const s = $(i.provider), n = A(i, e), r = b(i, e), o = new URLSearchParams({
92
- client_id: "arcgisonline",
98
+ const i = $(n.provider), o = A(n, t), r = I(n, t), a = new URLSearchParams({
99
+ client_id: s,
93
100
  redirect_uri: r,
94
101
  parent: window.location.origin,
95
102
  response_type: "token",
96
103
  force_login: "false",
97
- ...t.userId && { prepopulatedusername: t.userId },
98
- ...s === "social" && { socialLoginProviderName: i.provider },
99
- expiration: `${(t?.expires ?? Date.now() + w) - Date.now()}`
104
+ ...e.userId && { prepopulatedusername: e.userId },
105
+ ...i === "social" && { socialLoginProviderName: n.provider },
106
+ expiration: `${(e?.expires ?? Date.now() + w) - Date.now()}`
100
107
  });
101
- return `${n}?${o.toString()}`;
108
+ return `${o}?${a.toString()}`;
102
109
  }
103
- function $(i) {
104
- return J(i) ? "social" : i === "enterprise" ? "enterprise" : i.includes("oidc") ? "oidc" : "default";
110
+ function $(n) {
111
+ return q(n) ? "social" : n === "enterprise" ? "enterprise" : n.includes("oidc") ? "oidc" : "default";
105
112
  }
106
- function J(i) {
107
- return ["apple", "facebook", "github", "google"].includes(i);
113
+ function q(n) {
114
+ return ["apple", "facebook", "github", "google"].includes(n);
108
115
  }
109
- function A(i, t) {
110
- const e = h(i.orgUrlKey, t).toLowerCase(), s = $(i.provider);
111
- let n = "";
112
- switch (s) {
116
+ function A(n, e) {
117
+ const s = h(n.orgUrlKey, e).toLowerCase(), t = $(n.provider);
118
+ let i = "";
119
+ switch (t) {
113
120
  case "social":
114
- n = "social/";
121
+ i = "social/";
115
122
  break;
116
123
  case "enterprise":
117
- n = "saml/";
124
+ i = "saml/";
118
125
  break;
119
126
  case "oidc":
120
- n = `oidc/${i.provider.split("_")[1]}/`;
127
+ i = `oidc/${n.provider.split("_")[1]}/`;
121
128
  break;
122
129
  }
123
- return `${e}/sharing/rest/oauth2/${n}authorize`;
130
+ return `${s}/sharing/rest/oauth2/${i}authorize`;
124
131
  }
125
- function h(i, t) {
126
- return i?.startsWith("https://") ? i : i && t.customBaseUrl ? `https://${i}.${t.customBaseUrl}` : `https://${t.portalHostname}`;
132
+ function h(n, e) {
133
+ return n?.startsWith("https://") ? n : n && e.customBaseUrl ? `https://${n}.${e.customBaseUrl}` : `https://${e.portalHostname}`;
127
134
  }
128
- function b(i, t) {
129
- return `${h(i.orgUrlKey, t)}/home/accountswitcher-callback.html`;
135
+ function I(n, e) {
136
+ return `${h(n.orgUrlKey, e)}/home/accountswitcher-callback.html`;
130
137
  }
131
- function R({
132
- origin: i,
133
- redirectToClientUri: t,
134
- displaySignoutComplete: e
138
+ function z({
139
+ origin: n,
140
+ redirectToClientUri: e,
141
+ displaySignoutComplete: s
135
142
  }) {
136
- console.log("Signout complete", i, t, e);
143
+ console.log("Signout complete", n, e, s);
137
144
  }
138
- function D(i, t) {
139
- return p.findCredential(h(i.orgUrlKey, t), i.username);
145
+ function F(n, e) {
146
+ return g.findCredential(h(n.orgUrlKey, e), n.username);
140
147
  }
141
- function j(i, t) {
142
- const e = D(i, t);
143
- if (e)
144
- return e;
145
- const s = h(i.orgUrlKey, t), n = `${s}/home/check_sign_in_status.html#state=${JSON.stringify({
148
+ function G(n, e) {
149
+ const s = F(n, e);
150
+ if (s)
151
+ return s;
152
+ const t = h(n.orgUrlKey, e), i = `${t}/home/check_sign_in_status.html#state=${JSON.stringify({
146
153
  origin: window.location.origin,
147
- server: s,
148
- orgKey: s
154
+ server: t,
155
+ orgKey: t
149
156
  })}`;
150
- q(n, `iframe__for-${s}`);
157
+ Q(i, `iframe__for-${t}`);
151
158
  }
152
- function q(i, t) {
153
- const e = document.createElement("iframe");
154
- e.src = i, e.id = t, e.style.display = "none", document.body.appendChild(e);
159
+ function Q(n, e) {
160
+ const s = document.createElement("iframe");
161
+ s.src = n, s.id = e, s.style.display = "none", document.body.appendChild(s);
155
162
  }
156
163
  const k = 100;
157
- class z extends _ {
164
+ class V extends O {
158
165
  constructor() {
159
- super(), this.messages = K({ blocking: !0 }), this.clientId = "arcgisonline", this.targetUser = "", this.targetToken = "", this.linkedAccounts = [], this.loading = !1, this.signedInStatus = {}, this.showAssociatedAccountsWarning = !1, this.arcgisAccountSwitch = y(), this.arcgisClose = y(), this.listenOn(window, "message", this.handleMessageEvent);
166
+ super(), this.messages = P({ blocking: !0 }), this.targetUser = "", this.targetToken = "", this.accountAccess = {}, this.linkedAccounts = [], this.loading = !1, this.signedInStatus = {}, this.showAssociatedAccountsWarning = !1, this.clientId = "arcgisonline", this.arcgisAccountSwitch = b(), this.arcgisClose = b(), this.listenOn(window, "message", this.handleMessageEvent);
160
167
  }
161
168
  static {
162
- this.properties = { linkedAccounts: 16, userAccounts: 16, user: 16, credential: 16, alertOptions: 16, loading: 16, signedInStatus: 16, showAssociatedAccountsWarning: 16, portal: 0 };
169
+ this.properties = { linkedAccounts: 16, userAccounts: 16, user: 16, credential: 16, alertOptions: 16, loading: 16, signedInStatus: 16, showAssociatedAccountsWarning: 16, portal: 0, clientId: 1 };
163
170
  }
164
171
  static {
165
- this.styles = x;
172
+ this.styles = C;
166
173
  }
167
- willUpdate(t) {
168
- t.has("portal") && (this.user = this.portal?.user), (t.has("portal") || t.has("user")) && this.portal && this.user && this.findLinkedUsers();
174
+ willUpdate(e) {
175
+ e.has("portal") && (this.user = this.portal?.user), (e.has("portal") || e.has("user")) && this.portal && this.user && this.findLinkedUsers();
169
176
  }
170
- handleMessageEvent(t) {
171
- if (new URL(t.origin).hostname !== "localhost" && (t.origin.endsWith(".arcgis.com") || t.origin === window.location.origin)) {
172
- if (typeof t.data == "string") {
173
- JSON.parse(t.data).type === "token_exchange" && this.handleExchangeTokenMessage(t);
177
+ handleMessageEvent(e) {
178
+ if (new URL(e.origin).hostname !== "localhost" && (e.origin.endsWith(".arcgis.com") || e.origin === window.location.origin)) {
179
+ if (typeof e.data == "string") {
180
+ JSON.parse(e.data).type === "token_exchange" && this.handleExchangeTokenMessage(e);
174
181
  return;
175
182
  }
176
- if ("type" in t.data)
177
- switch (t.data.type) {
183
+ if ("type" in e.data)
184
+ switch (e.data.type) {
178
185
  case "signin":
179
- this.handleSigninMessage(t);
186
+ this.handleSigninMessage(e);
180
187
  return;
181
188
  case "signout":
182
- this.handleSignoutMessage(t);
189
+ this.handleSignoutMessage(e);
183
190
  return;
184
191
  case "linkUser":
185
- this.handleLinkUserMessage(t);
192
+ this.handleLinkUserMessage(e);
186
193
  return;
187
194
  case "token_exchange":
188
- this.handleExchangeTokenMessage(t);
195
+ this.handleExchangeTokenMessage(e);
189
196
  return;
190
197
  }
191
- if ("credential" in t.data) {
192
- this.handleSigninMessage(t);
198
+ if ("credential" in e.data) {
199
+ this.handleSigninMessage(e);
193
200
  return;
194
201
  }
195
- this.handleCheckSignInStatusMessage(t);
202
+ this.handleCheckSignInStatusMessage(e);
196
203
  }
197
204
  }
198
- handleSignoutMessage(t) {
199
- const { error: e, signout: s, accountOrigin: n, redirectToClientUri: r, displaySignoutComplete: o } = t.data;
200
- if (e && e !== "unknown") {
201
- console.error(e), this.showAlert("danger", this.messages.errors.signout);
205
+ handleSignoutMessage(e) {
206
+ const { error: s, signout: t, accountOrigin: i, redirectToClientUri: o, displaySignoutComplete: r } = e.data;
207
+ if (s && s !== "unknown") {
208
+ console.error(s), this.showAlert("danger", this.messages.errors.signout);
202
209
  return;
203
210
  }
204
- s && (this.user = void 0, this.credential = void 0, R({ origin: n, redirectToClientUri: r, displaySignoutComplete: o }));
211
+ t && (this.user = void 0, this.credential = void 0, z({ origin: i, redirectToClientUri: o, displaySignoutComplete: r }));
205
212
  }
206
- handleSigninMessage(t) {
207
- const { messages: e } = this, { error: s, status: n, state: r, access_token: o, ssl: a } = t.data;
208
- if (s) {
209
- console.error(s), this.showAlert("danger", e.errors.signin);
213
+ handleSigninMessage(e) {
214
+ const { messages: s, clientId: t } = this, { error: i, status: o, state: r, access_token: a, ssl: c } = e.data;
215
+ if (i) {
216
+ console.error(i), this.showAlert("danger", s.errors.signin);
210
217
  return;
211
218
  }
212
- if (n === "success") {
213
- const {
214
- portal: c,
215
- user: u
216
- /* , clientId */
217
- } = this, l = this.linkedAccounts.find((U) => U.username === r.user);
218
- l?.orgUrlKey === this.portal.urlKey && p.findCredential(`https://${c.portalHostname}`, u?.username)?.destroy();
219
- const m = {
219
+ if (o === "success") {
220
+ const { portal: l, user: u } = this, p = this.linkedAccounts.find((y) => y.username === r.user);
221
+ p?.orgUrlKey === this.portal.urlKey && g.findCredential(`https://${l.portalHostname}`, u?.username)?.destroy();
222
+ const f = {
220
223
  server: r.portalUrl,
221
224
  userId: r.user,
222
- token: o,
223
- expires: Number(t.data.expires_in) + Date.now(),
224
- ssl: a === void 0 || a !== "false"
225
+ token: a,
226
+ expires: Number(e.data.expires_in) + Date.now(),
227
+ ssl: c === void 0 || c !== "false"
225
228
  };
226
- p.registerToken(m);
227
- const f = B({
228
- account: l,
229
- credential: m,
230
- /* client_id: clientId, */
231
- portal: c
229
+ g.registerToken(f);
230
+ const U = j({
231
+ account: p,
232
+ credential: f,
233
+ // eslint-disable-next-line @typescript-eslint/naming-convention
234
+ client_id: t,
235
+ portal: l
232
236
  });
233
- window.self !== window.top ? window.top?.postMessage({ type: "navigate", url: f }) : window.location.href = f;
237
+ window.self !== window.top ? window.top?.postMessage({ type: "navigate", url: U }) : window.location.href = U;
234
238
  }
235
239
  }
236
- handleCheckSignInStatusMessage(t) {
237
- const { success: e, orgKey: s, server: n, userId: r, token: o, expires: a, ssl: c } = t.data;
238
- s && n && e && r && o && a && c !== void 0 && (this.signedInStatus[r] = { token: o, expires: a, ssl: c });
240
+ handleCheckSignInStatusMessage(e) {
241
+ const { success: s, orgKey: t, server: i, userId: o, token: r, expires: a, ssl: c } = e.data;
242
+ t && i && s && o && r && a && c !== void 0 && (this.signedInStatus[o] = { token: r, expires: a, ssl: c });
239
243
  }
240
- async handleLinkUserMessage(t) {
241
- const { error: e, username: s, access_token: n } = t.data, { portal: r, user: o, linkedAccounts: a, messages: c } = this;
242
- if (e) {
243
- if (e.toString().toLowerCase().includes("user denied your request"))
244
+ async handleLinkUserMessage(e) {
245
+ const { error: s, username: t, access_token: i } = e.data, { portal: o, user: r, linkedAccounts: a, messages: c } = this;
246
+ if (s) {
247
+ if (s.toString().toLowerCase().includes("user denied your request"))
244
248
  return;
245
249
  this.showAlert("danger", c.errors.accessAccount);
246
250
  return;
247
251
  }
248
- if (s === o?.username) {
252
+ if (t === r?.username) {
249
253
  this.showAlert("danger", c.errors.selfLink);
250
254
  return;
251
255
  }
252
- if (a.find((l) => l.username === s)) {
253
- this.showAlert("danger", g(c.errors.alreadyLinked, { username: s }));
256
+ if (a.find((u) => u.username === t)) {
257
+ this.showAlert("danger", m(c.errors.alreadyLinked, { username: t }));
254
258
  return;
255
259
  }
256
- const u = await C(r, s, n);
257
- if (u?.length) {
258
- this.userAccounts = u, this.targetUser = s ?? "", this.targetToken = n ?? "", this.showAssociatedAccountsWarning = !0;
260
+ const l = await T(o, t, i);
261
+ if (l?.length) {
262
+ this.userAccounts = l, this.targetUser = t ?? "", this.targetToken = i ?? "", this.showAssociatedAccountsWarning = !0;
259
263
  return;
260
264
  }
261
- this.linkAccount(s, n);
265
+ this.linkAccount(t, i);
262
266
  }
263
- handleExchangeTokenMessage(t) {
264
- const e = typeof t.data == "string" ? JSON.parse(t.data) : t.data;
265
- if (!(e.type && e.type !== "token_exchange")) {
266
- if (e.error)
267
- console.error(e);
268
- else if (e.status === "success" && this.targetUser) {
269
- const { portal: s, linkedAccounts: n, targetUser: r, clientId: o } = this, a = n.find((f) => f.username === r);
267
+ handleExchangeTokenMessage(e) {
268
+ const s = typeof e.data == "string" ? JSON.parse(e.data) : e.data;
269
+ if (!(s.type && s.type !== "token_exchange")) {
270
+ if (s.error)
271
+ console.error(s);
272
+ else if (s.status === "success" && this.targetUser) {
273
+ const { portal: t, linkedAccounts: i, targetUser: o, clientId: r } = this, a = i.find((f) => f.username === o);
270
274
  if (!a)
271
275
  return;
272
- const c = b(a, s), u = h(a.orgUrlKey, s), l = new URLSearchParams({
276
+ const c = I(a, t), l = h(a.orgUrlKey, t), u = new URLSearchParams({
273
277
  // eslint-disable-next-line @typescript-eslint/naming-convention
274
278
  response_type: "token",
275
279
  // eslint-disable-next-line @typescript-eslint/naming-convention
276
- client_id: o,
280
+ client_id: r,
277
281
  // eslint-disable-next-line @typescript-eslint/naming-convention
278
282
  redirect_uri: c,
279
- state: JSON.stringify({ user: a.username, portalUrl: u })
280
- }), m = `${A(a, s)}?${l.toString()}`;
281
- window.opener ? (window.opener.location.href = m, window.close()) : window.location.href = m;
283
+ state: JSON.stringify({ user: a.username, portalUrl: l })
284
+ }), p = `${A(a, t)}?${u.toString()}`;
285
+ window.opener ? (window.opener.location.href = p, window.close()) : window.location.href = p;
282
286
  }
283
287
  }
284
288
  }
@@ -287,79 +291,79 @@ class z extends _ {
287
291
  this.linkedAccounts = [], this.loading = !1;
288
292
  return;
289
293
  }
290
- this.linkedAccounts = await v(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((t) => t.orgUrlKey !== this.portal.urlKey).reduce((t, e) => (t[e.username] = j(e, this.portal) ?? null, t), {})), this.loading = !1;
294
+ this.linkedAccounts = await M(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((e) => e.orgUrlKey !== this.portal.urlKey).reduce((e, s) => (e[s.username] = G(s, this.portal) ?? null, e), {}), this.accountAccess = D({ accounts: this.linkedAccounts, clientId: this.clientId })), this.loading = !1;
291
295
  }
292
- async linkAccount(t, e) {
293
- const { portal: s, user: n } = this;
294
- if (!s || !n)
296
+ async linkAccount(e, s) {
297
+ const { portal: t, user: i } = this;
298
+ if (!t || !i)
295
299
  return;
296
- const r = await T({ portal: s, user: n, targetUser: t, targetToken: e }), { messages: o } = this;
297
- if (r.error) {
298
- this.showAlert("danger", g(o.errors.linkAccount, { username: t })), this.targetUser = "", this.userAccounts = [];
300
+ const o = await K({ portal: t, user: i, targetUser: e, targetToken: s }), { messages: r } = this;
301
+ if (o.error) {
302
+ this.showAlert("danger", m(r.errors.linkAccount, { username: e })), this.targetUser = "", this.userAccounts = [];
299
303
  return;
300
304
  }
301
- const a = this.userAccounts?.length ? o.success.linkAccountMultiple : o.success.linkAccount;
302
- this.showAlert("success", g(a, { username: t })), this.targetUser = "", this.userAccounts = [], await E(350), this.findLinkedUsers();
305
+ const a = this.userAccounts?.length ? r.success.linkAccountMultiple : r.success.linkAccount;
306
+ this.showAlert("success", m(a, { username: e })), this.targetUser = "", this.userAccounts = [], await E(350), this.findLinkedUsers();
303
307
  }
304
- async unlinkAccount(t) {
308
+ async unlinkAccount(e) {
305
309
  if (!this.portal || !this.user)
306
310
  return;
307
- const { messages: e, portal: s, user: n } = this, { success: r } = await M({ portal: s, user: n, linkedUsername: t.username });
308
- r ? this.showAlert("success", g(e.success.unlinkAccount, { username: t.username })) : this.showAlert("danger", g(e.errors.unlinkAccount, { username: t.username })), await this.findLinkedUsers();
311
+ const { messages: s, portal: t, user: i } = this, { success: o } = await N({ portal: t, user: i, linkedUsername: e.username });
312
+ o ? this.showAlert("success", m(s.success.unlinkAccount, { username: e.username })) : this.showAlert("danger", m(s.errors.unlinkAccount, { username: e.username })), await this.findLinkedUsers();
309
313
  }
310
314
  startAccountLink() {
311
- W(this.portal);
315
+ R(this.portal, this.clientId);
312
316
  }
313
- switchAccount(t) {
314
- const { portal: e, user: s, clientId: n } = this;
315
- if (!e || !s || !t)
317
+ switchAccount(e) {
318
+ const { portal: s, user: t, clientId: i } = this;
319
+ if (!s || !t || !e)
316
320
  return;
317
- const r = h(s.sourceJSON.orgUrlKey ?? "", e), o = p.findCredential(r, s.id || s.username);
318
- o && N({ config: { baseUrl: r, restBaseUrl: `${r}/sharing/rest` }, credential: o, clientId: n }), H(t, e);
321
+ const o = h(t.sourceJSON.orgUrlKey ?? "", s), r = g.findCredential(o, t.id || t.username);
322
+ r && B({ config: { baseUrl: o, restBaseUrl: `${o}/sharing/rest` }, credential: r, clientId: i }), J(e, s, i);
319
323
  }
320
- showAlert(t, e, s) {
324
+ showAlert(e, s, t) {
321
325
  this.alertOptions = {
322
- kind: t,
323
- title: s,
324
- message: e
326
+ kind: e,
327
+ title: t,
328
+ message: s
325
329
  };
326
330
  }
327
- showUnlinkConfirmation(t) {
328
- const { messages: e } = this;
331
+ showUnlinkConfirmation(e) {
332
+ const { messages: s } = this;
329
333
  this.alertOptions = {
330
334
  kind: "danger",
331
335
  icon: "exclamation-mark-triangle-f",
332
- title: e.unlinkTitle,
333
- message: e.unlinkWarning,
336
+ title: s.unlinkTitle,
337
+ message: s.unlinkWarning,
334
338
  actions: [
335
339
  {
336
- text: e.unlink,
340
+ text: s.unlink,
337
341
  kind: "danger",
338
342
  clickHandler: () => {
339
- this.alertOptions = void 0, this.unlinkAccount(t);
343
+ this.alertOptions = void 0, this.unlinkAccount(e);
340
344
  }
341
345
  }
342
346
  ]
343
347
  };
344
348
  }
345
349
  render() {
346
- const { linkedAccounts: t, user: e, portal: s, messages: n } = this;
347
- return !s || !e ? null : d`<calcite-dialog .heading=${n.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
350
+ const { linkedAccounts: e, accountAccess: s, user: t, portal: i, messages: o } = this;
351
+ return !i || !t ? null : d`<calcite-dialog .heading=${o.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
348
352
  this.arcgisClose.emit();
349
- }}><calcite-block .heading=${n.currentAccount} expanded class="current-account-block"><calcite-list .label=${g(n.currentAccountLabel, { username: e.username })} interaction-mode=static selection-mode=none class="current-account-list"><calcite-list-item><arcgis-portal-user-avatar .user=${e} .portal=${s} show-name .heading=${e.username} .description=${s.name || ""} slot=content-start></arcgis-portal-user-avatar></calcite-list-item></calcite-list></calcite-block>${t.length > 0 ? d`<calcite-block .heading=${n.chooseAccount} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${t.length >= k}>${n.linkAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${s} .linkedAccounts=${t} .signedInUsers=${Object.keys(this.signedInStatus).filter((r) => this.signedInStatus[r] !== null)} .label=${n.usersList} interactive @arcgisAccountSwitch=${(r) => {
353
+ }}><calcite-block .heading=${o.currentAccount} .description=${o.signedInAs} expanded class="current-account-block" tabindex=-1>${_(t.id ?? t.username, d`<calcite-block class="current-account" .label=${i.urlKey ? `${t.username}, ${i.name}` : t.username} heading-level=4 .heading=${t.username} .description=${i.urlKey ? `${t.fullName ?? t.username}, ${i.name}` : t.fullName ?? t.username}><calcite-avatar slot=content-start inert .fullName=${t.fullName ?? void 0} .username=${t.username} .userId=${t.id} .thumbnail=${H(t, i) ?? void 0}></calcite-avatar></calcite-block>`)}</calcite-block>${e.length > 0 ? d`<calcite-block .heading=${o.linkedAccounts} .description=${o.linkedAccountActions} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= k}>${o.addAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${i} .linkedAccounts=${e} .accountAccess=${s} .signedInUsers=${Object.keys(this.signedInStatus).filter((r) => this.signedInStatus[r] !== null)} interactive @arcgisAccountSwitch=${(r) => {
350
354
  this.switchAccount(r.detail.account);
351
355
  }} @arcgisAccountUnlink=${(r) => {
352
356
  this.showUnlinkConfirmation(r.detail.account);
353
- }}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${n.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>${I`<path d=${P.couple ?? O} fill=currentColor />`}</svg><h4>${n.emptyListTitle}</h4><p>${n.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${t.length >= k}>${n.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${t.length >= k}><div slot=message>${n.maxAccounts}</div></calcite-notice><calcite-alert .label=${n.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=${() => {
357
+ }}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${o.linkedAccounts} 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>${x`<path d=${W.couple ?? v} fill=currentColor />`}</svg><h4>${o.emptyListTitle}</h4><p>${o.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= k}>${o.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${e.length >= k}><div slot=message>${o.maxAccounts}</div></calcite-notice><calcite-alert .label=${o.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=${() => {
354
358
  this.alertOptions = void 0;
355
- }}>${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=${() => {
359
+ }}>${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=${i} .targetUser=${this.targetUser} .accounts=${this.userAccounts ?? []} @arcgisLinkAll=${() => {
356
360
  this.linkAccount(this.targetUser, this.targetToken);
357
361
  }} @arcgisCloseDialog=${() => {
358
362
  this.showAssociatedAccountsWarning = !1;
359
363
  }}></arcgis-portal-account-switcher-accounts>` || ""}`;
360
364
  }
361
365
  }
362
- L("arcgis-portal-account-switcher", z);
366
+ L("arcgis-portal-account-switcher", V);
363
367
  export {
364
- z as ArcgisPortalAccountSwitcher
368
+ V as ArcgisPortalAccountSwitcher
365
369
  };
@@ -1,8 +1,6 @@
1
1
  import "@esri/calcite-components/components/calcite-dialog";
2
2
  import "@esri/calcite-components/components/calcite-block";
3
- import "@esri/calcite-components/components/calcite-list";
4
- import "@esri/calcite-components/components/calcite-list-item";
5
- import "../arcgis-portal-user-avatar/index.js";
3
+ import "@esri/calcite-components/components/calcite-avatar";
6
4
  import "@esri/calcite-components/components/calcite-button";
7
5
  import "../arcgis-portal-account-switcher-list/index.js";
8
6
  import "@esri/calcite-components/components/calcite-notice";
@@ -0,0 +1,6 @@
1
+ export type AccountAccess = Record<string, AccountStatus>;
2
+
3
+ export interface AccountStatus {
4
+ disabled: boolean;
5
+ allowed: boolean;
6
+ }