@esri/hub-common 9.13.0 → 9.13.1

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,285 @@
1
+ import { getProp, getWithDefault } from ".";
2
+ /**
3
+ * Hash of Hub API end points so updates
4
+ * are centralized
5
+ */
6
+ var hubApiEndpoints = {
7
+ domains: "/api/v3/domains",
8
+ search: "/api/v3/datasets",
9
+ discussions: "/api/discussions/v1",
10
+ };
11
+ /**
12
+ * @internal
13
+ * Thin class just used to enable getters
14
+ *
15
+ * This class should not be used by anything other than
16
+ * the ArcGISContext class
17
+ */
18
+ var ArcGISContextState = /** @class */ (function () {
19
+ function ArcGISContextState(opts) {
20
+ this._portalUrl = "https://www.arcgis.com";
21
+ this.id = opts.id;
22
+ this._portalUrl = opts.portalUrl;
23
+ this._hubUrl = opts.hubUrl;
24
+ if (opts.authentication) {
25
+ this._authentication = opts.authentication;
26
+ }
27
+ if (opts.portalSelf) {
28
+ this._portalSelf = opts.portalSelf;
29
+ }
30
+ if (opts.currentUser) {
31
+ this._currentUser = opts.currentUser;
32
+ }
33
+ }
34
+ Object.defineProperty(ArcGISContextState.prototype, "session", {
35
+ /**
36
+ * Return the UserSession if authenticated
37
+ */
38
+ get: function () {
39
+ return this._authentication;
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ Object.defineProperty(ArcGISContextState.prototype, "isAuthenticated", {
45
+ /**
46
+ * Return boolean indicating if authenticatio is present
47
+ */
48
+ get: function () {
49
+ return !!this._authentication;
50
+ },
51
+ enumerable: false,
52
+ configurable: true
53
+ });
54
+ Object.defineProperty(ArcGISContextState.prototype, "userRequestOptions", {
55
+ /**
56
+ * Return `IUserRequestOptions`, which is used for REST-JS
57
+ * functions which require authentication information.
58
+ *
59
+ * If context is not authenticated, this function will throw
60
+ */
61
+ get: function () {
62
+ if (this.isAuthenticated) {
63
+ return {
64
+ authentication: this._authentication,
65
+ portal: this.sharingApiUrl,
66
+ };
67
+ }
68
+ },
69
+ enumerable: false,
70
+ configurable: true
71
+ });
72
+ Object.defineProperty(ArcGISContextState.prototype, "requestOptions", {
73
+ /**
74
+ * Return `IRequestOptions`, which is used by REST-JS functions
75
+ * which *may* use authentication information if provided.
76
+ *
77
+ * If context is not authenticated, this function just returns
78
+ * the `portal` property, which informs REST-JS what Sharing API
79
+ * instance to use (i.e. AGO, Enterprise etc)
80
+ */
81
+ get: function () {
82
+ var ro = {
83
+ portal: this.sharingApiUrl,
84
+ };
85
+ if (this.isAuthenticated) {
86
+ ro = {
87
+ authentication: this._authentication,
88
+ portal: this.sharingApiUrl,
89
+ };
90
+ }
91
+ return ro;
92
+ },
93
+ enumerable: false,
94
+ configurable: true
95
+ });
96
+ Object.defineProperty(ArcGISContextState.prototype, "hubRequestOptions", {
97
+ /**
98
+ * Return a `IHubRequestOptions` object
99
+ */
100
+ get: function () {
101
+ // We may add more logic around what is returned in some corner cases
102
+ return {
103
+ authentication: this.session,
104
+ isPortal: this.isPortal,
105
+ portalSelf: this.portal,
106
+ hubApiUrl: this.hubUrl,
107
+ };
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ Object.defineProperty(ArcGISContextState.prototype, "portalUrl", {
113
+ // ==============================
114
+ // Getters / Computed Properties
115
+ // ==============================
116
+ /**
117
+ * Return the portal url.
118
+ *
119
+ * If authenticated @ ArcGIS Online, it will return
120
+ * the https://org.env.arcgis.com
121
+ *
122
+ * If authenticated @ ArcGIS Enterprise, it will return
123
+ * https://portalHostname, which includes the web adaptor
124
+ */
125
+ get: function () {
126
+ if (this.isAuthenticated) {
127
+ if (this.isPortal) {
128
+ return "https://" + this._portalSelf.portalHostname;
129
+ }
130
+ else {
131
+ return "https://" + this._portalSelf.urlKey + "." + this._portalSelf.customBaseUrl;
132
+ }
133
+ }
134
+ else {
135
+ return this._portalUrl;
136
+ }
137
+ },
138
+ enumerable: false,
139
+ configurable: true
140
+ });
141
+ Object.defineProperty(ArcGISContextState.prototype, "sharingApiUrl", {
142
+ /**
143
+ * Returns the url to the sharing api
144
+ * i.e. https://myorg.maps.arcgis.com/sharing/rest
145
+ */
146
+ get: function () {
147
+ return this.portalUrl + "/sharing/rest";
148
+ },
149
+ enumerable: false,
150
+ configurable: true
151
+ });
152
+ Object.defineProperty(ArcGISContextState.prototype, "hubUrl", {
153
+ get: function () {
154
+ return this._hubUrl;
155
+ },
156
+ enumerable: false,
157
+ configurable: true
158
+ });
159
+ Object.defineProperty(ArcGISContextState.prototype, "isPortal", {
160
+ /**
161
+ * Returns boolean indicating if the backing system
162
+ * is ArcGIS Enterprise (formerly ArcGIS Portal) or not
163
+ */
164
+ get: function () {
165
+ return this._portalSelf
166
+ ? this._portalSelf.isPortal
167
+ : this._portalUrl.indexOf("arcgis.com") === -1;
168
+ },
169
+ enumerable: false,
170
+ configurable: true
171
+ });
172
+ Object.defineProperty(ArcGISContextState.prototype, "discussionsServiceUrl", {
173
+ // Hub APIs
174
+ // ----------
175
+ // Discussions
176
+ get: function () {
177
+ if (this._hubUrl) {
178
+ return "" + this._hubUrl + hubApiEndpoints.discussions;
179
+ }
180
+ },
181
+ enumerable: false,
182
+ configurable: true
183
+ });
184
+ Object.defineProperty(ArcGISContextState.prototype, "hubSearchServiceUrl", {
185
+ // Hub Search
186
+ get: function () {
187
+ if (this._hubUrl) {
188
+ return "" + this._hubUrl + hubApiEndpoints.search;
189
+ }
190
+ },
191
+ enumerable: false,
192
+ configurable: true
193
+ });
194
+ Object.defineProperty(ArcGISContextState.prototype, "domainServiceUrl", {
195
+ // Domain
196
+ get: function () {
197
+ if (this._hubUrl) {
198
+ return "" + this._hubUrl + hubApiEndpoints.domains;
199
+ }
200
+ },
201
+ enumerable: false,
202
+ configurable: true
203
+ });
204
+ Object.defineProperty(ArcGISContextState.prototype, "eventsConfig", {
205
+ // Events
206
+ // returns `{serviceId: '3ef..', publicViewId: 'bc3...'}
207
+ get: function () {
208
+ if (this._portalSelf) {
209
+ return getProp(this._portalSelf, "portalProperties.hub.settings.events");
210
+ }
211
+ },
212
+ enumerable: false,
213
+ configurable: true
214
+ });
215
+ Object.defineProperty(ArcGISContextState.prototype, "hubEnabled", {
216
+ /**
217
+ * Returns boolean indicating if the current user
218
+ * belongs to an organization that has licensed
219
+ * ArcGIS Hub
220
+ */
221
+ get: function () {
222
+ return getWithDefault(this._portalSelf, "portalProperties.hub.enabled", false);
223
+ },
224
+ enumerable: false,
225
+ configurable: true
226
+ });
227
+ Object.defineProperty(ArcGISContextState.prototype, "communityOrgId", {
228
+ /**
229
+ * Return Hub Community Org Id, if defined
230
+ */
231
+ get: function () {
232
+ if (this._portalSelf) {
233
+ return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.orgId");
234
+ }
235
+ },
236
+ enumerable: false,
237
+ configurable: true
238
+ });
239
+ Object.defineProperty(ArcGISContextState.prototype, "communityOrgHostname", {
240
+ get: function () {
241
+ if (this._portalSelf) {
242
+ return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
243
+ }
244
+ },
245
+ enumerable: false,
246
+ configurable: true
247
+ });
248
+ Object.defineProperty(ArcGISContextState.prototype, "communityOrgUrl", {
249
+ get: function () {
250
+ if (this.communityOrgHostname) {
251
+ return "https://" + this.communityOrgHostname;
252
+ }
253
+ },
254
+ enumerable: false,
255
+ configurable: true
256
+ });
257
+ Object.defineProperty(ArcGISContextState.prototype, "helperServices", {
258
+ // Platform API service urls are all in helperServices
259
+ // and not consistent to expose as urls
260
+ get: function () {
261
+ if (this._portalSelf) {
262
+ return this._portalSelf.helperServices;
263
+ }
264
+ },
265
+ enumerable: false,
266
+ configurable: true
267
+ });
268
+ Object.defineProperty(ArcGISContextState.prototype, "currentUser", {
269
+ get: function () {
270
+ return this._currentUser;
271
+ },
272
+ enumerable: false,
273
+ configurable: true
274
+ });
275
+ Object.defineProperty(ArcGISContextState.prototype, "portal", {
276
+ get: function () {
277
+ return this._portalSelf;
278
+ },
279
+ enumerable: false,
280
+ configurable: true
281
+ });
282
+ return ArcGISContextState;
283
+ }());
284
+ export { ArcGISContextState };
285
+ //# sourceMappingURL=ArcGISContextState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcGISContextState.js","sourceRoot":"","sources":["../../src/ArcGISContextState.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAsB,MAAM,GAAG,CAAC;AAEhE;;;GAGG;AACH,IAAM,eAAe,GAAG;IACtB,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,kBAAkB;IAC1B,WAAW,EAAE,qBAAqB;CACnC,CAAC;AA6CF;;;;;;GAMG;AACH;IAYE,4BAAY,IAAgC;QARpC,eAAU,GAAW,wBAAwB,CAAC;QASpD,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC;SAC5C;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;SACpC;QAED,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;SACtC;IACH,CAAC;IAKD,sBAAW,uCAAO;QAHlB;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,eAAe,CAAC;QAC9B,CAAC;;;OAAA;IAKD,sBAAW,+CAAe;QAH1B;;WAEG;aACH;YACE,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;QAChC,CAAC;;;OAAA;IAQD,sBAAW,kDAAkB;QAN7B;;;;;WAKG;aACH;YACE,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,OAAO;oBACL,cAAc,EAAE,IA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D,CAAC;aACH;QACH,CAAC;;;OAAA;IAED,sBAAW,oDAAoB;aAA/B;YACE,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO,OAAO,CACZ,IAAI,CAAC,WAAW,EAChB,2DAA2D,CAC5D,CAAC;aACH;QACH,CAAC;;;OAAA;IAED,sBAAW,+CAAe;aAA1B;YACE,IAAI,IAAI,CAAC,oBAAoB,EAAE;gBAC7B,OAAO,aAAW,IAAI,CAAC,oBAAsB,CAAC;aAC/C;QACH,CAAC;;;OAAA;IAID,sBAAW,8CAAc;QAFzB,sDAAsD;QACtD,uCAAuC;aACvC;YACE,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;aACxC;QACH,CAAC;;;OAAA;IAED,sBAAW,2CAAW;aAAtB;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAED,sBAAW,sCAAM;aAAjB;YACE,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IACH,yBAAC;AAAD,CAAC,AAjOD,IAiOC"}
@@ -2,16 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArcGISContext = void 0;
4
4
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
5
- const _1 = require(".");
6
- /**
7
- * Hash of Hub API end points so updates
8
- * are centralized
9
- */
10
- const hubApiEndpoints = {
11
- domains: "/api/v3/domains",
12
- search: "/api/v3/datasets",
13
- discussions: "/api/discussions/v1",
14
- };
5
+ const ArcGISContextState_1 = require("./ArcGISContextState");
15
6
  /**
16
7
  * Application Context Object
17
8
  *
@@ -67,19 +58,69 @@ class ArcGISContext {
67
58
  * store that along with current user
68
59
  */
69
60
  async initialize() {
61
+ let stateOpts = {
62
+ id: this.id,
63
+ portalUrl: this._portalUrl,
64
+ hubUrl: this._hubUrl,
65
+ };
70
66
  if (this._authentication) {
71
67
  this.log(`ArcGISContext-${this.id}: Initializing`);
72
68
  const ps = await arcgis_rest_portal_1.getSelf({ authentication: this._authentication });
73
69
  this._portalSelf = ps;
74
70
  this._currentUser = ps.user;
71
+ stateOpts = {
72
+ id: this.id,
73
+ portalUrl: this._portalUrl,
74
+ hubUrl: this._hubUrl,
75
+ portalSelf: this._portalSelf,
76
+ currentUser: this._currentUser,
77
+ authentication: this._authentication,
78
+ };
75
79
  }
80
+ // update the state
81
+ this._state = new ArcGISContextState_1.ArcGISContextState(stateOpts);
76
82
  }
77
- // Set authentication after the instance is up and running
83
+ /**
84
+ * Set the Authentication (UserSession) for the context.
85
+ * This should be called when a user signs into a running
86
+ * application.
87
+ * @param auth
88
+ */
78
89
  async setAuthentication(auth) {
79
90
  this._authentication = auth;
80
91
  this._portalUrl = auth.portal.replace("/sharing/rest", "");
81
92
  await this.initialize();
82
93
  }
94
+ /**
95
+ * Clear the Authentication (UserSession). This should be
96
+ * called when a user signs out of an application, but
97
+ * the application continues running
98
+ */
99
+ clearAuthentication() {
100
+ // Reset the portalUrl from the org url to the base url
101
+ // for ArcGIS Enterprise, we just leave the _portalUrl as-is
102
+ if (!this._state.isPortal) {
103
+ this._portalUrl = getPortalBaseFromOrgUrl(this._portalUrl);
104
+ }
105
+ // Clear the auth, portalSelf and currentUser props
106
+ this._authentication = null;
107
+ this._portalSelf = null;
108
+ this._currentUser = null;
109
+ this._state = new ArcGISContextState_1.ArcGISContextState({
110
+ id: this.id,
111
+ portalUrl: this._portalUrl,
112
+ hubUrl: this._hubUrl,
113
+ });
114
+ }
115
+ /**
116
+ * Return a reference to the current state.
117
+ * When `.setAuthentication()` or `.clearAuthenentication()` are
118
+ * called, the state will be re-created. This is done so frameworks
119
+ * like React or Ember can detect changes.
120
+ */
121
+ get state() {
122
+ return this._state;
123
+ }
83
124
  /**
84
125
  * @internal
85
126
  * Log debugging messages to the console
@@ -91,174 +132,6 @@ class ArcGISContext {
91
132
  console.info(message);
92
133
  }
93
134
  }
94
- /**
95
- * Return the UserSession if authenticated
96
- */
97
- get session() {
98
- return this._authentication;
99
- }
100
- /**
101
- * Return boolean indicating if authenticatio is present
102
- */
103
- get isAuthenticated() {
104
- return !!this._authentication;
105
- }
106
- /**
107
- * Return `IUserRequestOptions`, which is used for REST-JS
108
- * functions which require authentication information.
109
- *
110
- * If context is not authenticated, this function will throw
111
- */
112
- get userRequestOptions() {
113
- if (this.isAuthenticated) {
114
- return {
115
- authentication: this._authentication,
116
- portal: this.sharingApiUrl,
117
- };
118
- }
119
- }
120
- /**
121
- * Return `IRequestOptions`, which is used by REST-JS functions
122
- * which *may* use authentication information if provided.
123
- *
124
- * If context is not authenticated, this function just returns
125
- * the `portal` property, which informs REST-JS what Sharing API
126
- * instance to use (i.e. AGO, Enterprise etc)
127
- */
128
- get requestOptions() {
129
- let ro = {
130
- portal: this.sharingApiUrl,
131
- };
132
- if (this.isAuthenticated) {
133
- ro = {
134
- authentication: this._authentication,
135
- portal: this.sharingApiUrl,
136
- };
137
- }
138
- return ro;
139
- }
140
- /**
141
- * Return a `IHubRequestOptions` object
142
- */
143
- get hubRequestOptions() {
144
- // We may add more logic around what is returned in some corner cases
145
- return {
146
- authentication: this.session,
147
- isPortal: this.isPortal,
148
- portalSelf: this.portal,
149
- hubApiUrl: this.hubUrl,
150
- };
151
- }
152
- // ==============================
153
- // Getters / Computed Properties
154
- // ==============================
155
- /**
156
- * Return the portal url.
157
- *
158
- * If authenticated @ ArcGIS Online, it will return
159
- * the https://org.env.arcgis.com
160
- *
161
- * If authenticated @ ArcGIS Enterprise, it will return
162
- * https://portalHostname, which includes the web adaptor
163
- */
164
- get portalUrl() {
165
- if (this.isAuthenticated) {
166
- if (this.isPortal) {
167
- return `https://${this._portalSelf.portalHostname}`;
168
- }
169
- else {
170
- return `https://${this._portalSelf.urlKey}.${this._portalSelf.customBaseUrl}`;
171
- }
172
- }
173
- else {
174
- return this._portalUrl;
175
- }
176
- }
177
- /**
178
- * Returns the url to the sharing api
179
- * i.e. https://myorg.maps.arcgis.com/sharing/rest
180
- */
181
- get sharingApiUrl() {
182
- return `${this.portalUrl}/sharing/rest`;
183
- }
184
- get hubUrl() {
185
- return this._hubUrl;
186
- }
187
- /**
188
- * Returns boolean indicating if the backing system
189
- * is ArcGIS Enterprise (formerly ArcGIS Portal) or not
190
- */
191
- get isPortal() {
192
- return this._portalSelf
193
- ? this._portalSelf.isPortal
194
- : this._portalUrl.indexOf("arcgis.com") === -1;
195
- }
196
- // Hub APIs
197
- // ----------
198
- // Discussions
199
- get discussionsServiceUrl() {
200
- if (this._hubUrl) {
201
- return `${this._hubUrl}${hubApiEndpoints.discussions}`;
202
- }
203
- }
204
- // Hub Search
205
- get hubSearchServiceUrl() {
206
- if (this._hubUrl) {
207
- return `${this._hubUrl}${hubApiEndpoints.search}`;
208
- }
209
- }
210
- // Domain
211
- get domainServiceUrl() {
212
- if (this._hubUrl) {
213
- return `${this._hubUrl}${hubApiEndpoints.domains}`;
214
- }
215
- }
216
- // Events
217
- // returns `{serviceId: '3ef..', publicViewId: 'bc3...'}
218
- get eventsConfig() {
219
- if (this._portalSelf) {
220
- return _1.getProp(this._portalSelf, "portalProperties.hub.settings.events");
221
- }
222
- }
223
- /**
224
- * Returns boolean indicating if the current user
225
- * belongs to an organization that has licensed
226
- * ArcGIS Hub
227
- */
228
- get hubEnabled() {
229
- return _1.getWithDefault(this._portalSelf, "portalProperties.hub.enabled", false);
230
- }
231
- /**
232
- * Return Hub Community Org Id, if defined
233
- */
234
- get communityOrgId() {
235
- if (this._portalSelf) {
236
- return _1.getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.orgId");
237
- }
238
- }
239
- get communityOrgHostname() {
240
- if (this._portalSelf) {
241
- return _1.getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
242
- }
243
- }
244
- get communityOrgUrl() {
245
- if (this.communityOrgHostname) {
246
- return `https://${this.communityOrgHostname}`;
247
- }
248
- }
249
- // Platform API service urls are all in helperServices
250
- // and not consistent to expose as urls
251
- get helperServices() {
252
- if (this._portalSelf) {
253
- return this._portalSelf.helperServices;
254
- }
255
- }
256
- get currentUser() {
257
- return this._currentUser;
258
- }
259
- get portal() {
260
- return this._portalSelf;
261
- }
262
135
  }
263
136
  exports.ArcGISContext = ArcGISContext;
264
137
  /**
@@ -281,4 +154,20 @@ function getHubApiFromPortalUrl(portalUrl) {
281
154
  }
282
155
  return result;
283
156
  }
157
+ function getPortalBaseFromOrgUrl(orgUrl) {
158
+ let result;
159
+ if (orgUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
160
+ result = "https://qaext.arcgis.com";
161
+ }
162
+ else if (orgUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
163
+ result = "https://devext.arcgis.com";
164
+ }
165
+ else {
166
+ /* istanbul ignore else */
167
+ if (orgUrl.match(/(www|\.maps)\.arcgis.com/)) {
168
+ result = "https://www.arcgis.com";
169
+ }
170
+ }
171
+ return result;
172
+ }
284
173
  //# sourceMappingURL=ArcGISContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGISContext.js","sourceRoot":"","sources":["../../src/ArcGISContext.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAM5D,wBAAgE;AAGhE;;;GAGG;AACH,MAAM,eAAe,GAAG;IACtB,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,kBAAkB;IAC1B,WAAW,EAAE,qBAAqB;CACnC,CAAC;AA+BF;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IAoBxB;;;;OAIG;IACH,YAAoB,IAA2B;QAfvC,eAAU,GAAW,wBAAwB,CAAC;QAQ9C,WAAM,GAAG,KAAK,CAAC;QAQrB,4CAA4C;QAC5C,IAAI,CAAC,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;SAC1B;QACD,IAAI,CAAC,GAAG,CA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