IdentityManager-RSGL7L3S.js 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803
  1. import {
  2. M,
  3. e2,
  4. e4 as e3
  5. } from "./chunk-PB5D5C6Y.js";
  6. import {
  7. n2 as n4,
  8. v as v2
  9. } from "./chunk-GZBNC76D.js";
  10. import "./chunk-2TTT3V5O.js";
  11. import "./chunk-IOZKU7B2.js";
  12. import {
  13. s as s3
  14. } from "./chunk-S6EFEKAU.js";
  15. import "./chunk-I4RYNNL6.js";
  16. import "./chunk-TV3CFJQR.js";
  17. import {
  18. l as l2
  19. } from "./chunk-TJV6ODRM.js";
  20. import "./chunk-HWSWTWZD.js";
  21. import "./chunk-ZLNEXZAN.js";
  22. import "./chunk-5UVJ64RB.js";
  23. import {
  24. n as n3
  25. } from "./chunk-IM3LVQXV.js";
  26. import "./chunk-55RWC67C.js";
  27. import "./chunk-HZRKBTHJ.js";
  28. import {
  29. U,
  30. t as t2
  31. } from "./chunk-DVUG3KID.js";
  32. import {
  33. n as n5,
  34. s as s4
  35. } from "./chunk-FWSQEIAR.js";
  36. import {
  37. Bt,
  38. F,
  39. I,
  40. J,
  41. L,
  42. Q,
  43. Z,
  44. j,
  45. y as y2,
  46. z
  47. } from "./chunk-VEGAOVMY.js";
  48. import "./chunk-YEJL5NEF.js";
  49. import {
  50. e,
  51. l3 as l,
  52. n2 as n,
  53. n5 as n2,
  54. y3 as y
  55. } from "./chunk-2Z2TG5CU.js";
  56. import "./chunk-6KZ2LTDA.js";
  57. import "./chunk-U2XHEJM7.js";
  58. import "./chunk-SQOPWYIT.js";
  59. import {
  60. D,
  61. p as p2,
  62. r2 as r,
  63. v
  64. } from "./chunk-V6P2MAQQ.js";
  65. import {
  66. s,
  67. s3 as s2
  68. } from "./chunk-E5O6P5I2.js";
  69. import {
  70. p,
  71. t
  72. } from "./chunk-SPWQ3AWG.js";
  73. import "./chunk-2TIUKVZN.js";
  74. import "./chunk-YXWMMD76.js";
  75. import "./chunk-S5KM4IGW.js";
  76. // node_modules/@arcgis/core/identity/IdentityForm.js
  77. var a = { base: "esri-identity-form", group: "esri-identity-form__group", label: "esri-identity-form__label", footer: "esri-identity-form__footer", esriInput: "esri-input", esriButton: "esri-button", esriButtonSecondary: "esri-button--secondary" };
  78. var l3 = "ArcGIS Online";
  79. var p3 = class extends M {
  80. constructor(s8, e5) {
  81. super(s8, e5), this._usernameInputNode = null, this._passwordInputNode = null, this.signingIn = false, this.server = null, this.resource = null, this.error = null, this.oAuthPrompt = false;
  82. }
  83. render() {
  84. const { error: s8, server: e5, resource: t4, signingIn: o, oAuthPrompt: n6, messages: p6 } = this, d2 = n4("div", { class: a.group }, s3(n6 ? p6.oAuthInfo : p6.info, { server: e5 && /\.arcgis\.com/i.test(e5) ? l3 : e5, resource: `(${t4 || p6.lblItem})` })), c = n6 ? null : n4("div", { class: a.group, key: "username" }, n4("label", { class: a.label }, p6.lblUser, n4("input", { value: "", required: true, autocomplete: "off", spellcheck: false, type: "text", bind: this, afterCreate: v2, "data-node-ref": "_usernameInputNode", class: a.esriInput }))), m = n6 ? null : n4("div", { class: a.group, key: "password" }, n4("label", { class: a.label }, p6.lblPwd, n4("input", { value: "", required: true, type: "password", bind: this, afterCreate: v2, "data-node-ref": "_passwordInputNode", class: a.esriInput }))), h = n4("div", { class: this.classes(a.group, a.footer) }, n4("input", { type: "submit", disabled: !!o, value: o ? p6.lblSigning : p6.lblOk, class: a.esriButton }), n4("input", { type: "button", value: p6.lblCancel, bind: this, onclick: this._cancel, class: this.classes(a.esriButton, a.esriButtonSecondary) })), b2 = s8 ? n4("div", null, s8.details && s8.details.httpStatus ? p6.invalidUser : p6.noAuthService) : null;
  85. return n4("form", { class: a.base, bind: this, onsubmit: this._submit }, d2, b2, c, m, h);
  86. }
  87. _cancel() {
  88. this._set("signingIn", false), this._usernameInputNode && (this._usernameInputNode.value = ""), this._passwordInputNode && (this._passwordInputNode.value = ""), this.emit("cancel");
  89. }
  90. _submit(s8) {
  91. s8.preventDefault(), this._set("signingIn", true);
  92. const e5 = this.oAuthPrompt ? {} : { username: this._usernameInputNode && this._usernameInputNode.value, password: this._passwordInputNode && this._passwordInputNode.value };
  93. this.emit("submit", e5);
  94. }
  95. };
  96. e([y(), e2("esri/identity/t9n/identity")], p3.prototype, "messages", void 0), e([y()], p3.prototype, "signingIn", void 0), e([y()], p3.prototype, "server", void 0), e([y()], p3.prototype, "resource", void 0), e([y()], p3.prototype, "error", void 0), e([y()], p3.prototype, "oAuthPrompt", void 0), p3 = e([n2("esri.identity.IdentityForm")], p3);
  97. var d = p3;
  98. // node_modules/tabbable/dist/index.esm.js
  99. var candidateSelectors = ["input", "select", "textarea", "a[href]", "button", "[tabindex]:not(slot)", "audio[controls]", "video[controls]", '[contenteditable]:not([contenteditable="false"])', "details>summary:first-of-type", "details"];
  100. var candidateSelector = candidateSelectors.join(",");
  101. var NoElement = typeof Element === "undefined";
  102. var matches = NoElement ? function() {
  103. } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  104. var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
  105. return element.getRootNode();
  106. } : function(element) {
  107. return element.ownerDocument;
  108. };
  109. var getCandidates = function getCandidates2(el, includeContainer, filter) {
  110. var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
  111. if (includeContainer && matches.call(el, candidateSelector)) {
  112. candidates.unshift(el);
  113. }
  114. candidates = candidates.filter(filter);
  115. return candidates;
  116. };
  117. var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) {
  118. var candidates = [];
  119. var elementsToCheck = Array.from(elements);
  120. while (elementsToCheck.length) {
  121. var element = elementsToCheck.shift();
  122. if (element.tagName === "SLOT") {
  123. var assigned = element.assignedElements();
  124. var content = assigned.length ? assigned : element.children;
  125. var nestedCandidates = getCandidatesIteratively2(content, true, options);
  126. if (options.flatten) {
  127. candidates.push.apply(candidates, nestedCandidates);
  128. } else {
  129. candidates.push({
  130. scopeParent: element,
  131. candidates: nestedCandidates
  132. });
  133. }
  134. } else {
  135. var validCandidate = matches.call(element, candidateSelector);
  136. if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
  137. candidates.push(element);
  138. }
  139. var shadowRoot = element.shadowRoot || typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
  140. var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element);
  141. if (shadowRoot && validShadowRoot) {
  142. var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options);
  143. if (options.flatten) {
  144. candidates.push.apply(candidates, _nestedCandidates);
  145. } else {
  146. candidates.push({
  147. scopeParent: element,
  148. candidates: _nestedCandidates
  149. });
  150. }
  151. } else {
  152. elementsToCheck.unshift.apply(elementsToCheck, element.children);
  153. }
  154. }
  155. }
  156. return candidates;
  157. };
  158. var getTabindex = function getTabindex2(node, isScope) {
  159. if (node.tabIndex < 0) {
  160. if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute("tabindex"), 10))) {
  161. return 0;
  162. }
  163. }
  164. return node.tabIndex;
  165. };
  166. var sortOrderedTabbables = function sortOrderedTabbables2(a2, b2) {
  167. return a2.tabIndex === b2.tabIndex ? a2.documentOrder - b2.documentOrder : a2.tabIndex - b2.tabIndex;
  168. };
  169. var isInput = function isInput2(node) {
  170. return node.tagName === "INPUT";
  171. };
  172. var isHiddenInput = function isHiddenInput2(node) {
  173. return isInput(node) && node.type === "hidden";
  174. };
  175. var isDetailsWithSummary = function isDetailsWithSummary2(node) {
  176. var r3 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
  177. return child.tagName === "SUMMARY";
  178. });
  179. return r3;
  180. };
  181. var getCheckedRadio = function getCheckedRadio2(nodes, form) {
  182. for (var i3 = 0; i3 < nodes.length; i3++) {
  183. if (nodes[i3].checked && nodes[i3].form === form) {
  184. return nodes[i3];
  185. }
  186. }
  187. };
  188. var isTabbableRadio = function isTabbableRadio2(node) {
  189. if (!node.name) {
  190. return true;
  191. }
  192. var radioScope = node.form || getRootNode(node);
  193. var queryRadios = function queryRadios2(name) {
  194. return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
  195. };
  196. var radioSet;
  197. if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
  198. radioSet = queryRadios(window.CSS.escape(node.name));
  199. } else {
  200. try {
  201. radioSet = queryRadios(node.name);
  202. } catch (err) {
  203. console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
  204. return false;
  205. }
  206. }
  207. var checked = getCheckedRadio(radioSet, node.form);
  208. return !checked || checked === node;
  209. };
  210. var isRadio = function isRadio2(node) {
  211. return isInput(node) && node.type === "radio";
  212. };
  213. var isNonTabbableRadio = function isNonTabbableRadio2(node) {
  214. return isRadio(node) && !isTabbableRadio(node);
  215. };
  216. var isNodeAttached = function isNodeAttached2(node) {
  217. var _nodeRootHost;
  218. var nodeRootHost = getRootNode(node).host;
  219. var attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && _nodeRootHost.ownerDocument.contains(nodeRootHost) || node.ownerDocument.contains(node));
  220. while (!attached && nodeRootHost) {
  221. var _nodeRootHost2;
  222. nodeRootHost = getRootNode(nodeRootHost).host;
  223. attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && _nodeRootHost2.ownerDocument.contains(nodeRootHost));
  224. }
  225. return attached;
  226. };
  227. var isZeroArea = function isZeroArea2(node) {
  228. var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
  229. return width === 0 && height === 0;
  230. };
  231. var isHidden = function isHidden2(node, _ref) {
  232. var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
  233. if (getComputedStyle(node).visibility === "hidden") {
  234. return true;
  235. }
  236. var isDirectSummary = matches.call(node, "details>summary:first-of-type");
  237. var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
  238. if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
  239. return true;
  240. }
  241. if (!displayCheck || displayCheck === "full" || displayCheck === "legacy-full") {
  242. if (typeof getShadowRoot === "function") {
  243. var originalNode = node;
  244. while (node) {
  245. var parentElement = node.parentElement;
  246. var rootNode = getRootNode(node);
  247. if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
  248. return isZeroArea(node);
  249. } else if (node.assignedSlot) {
  250. node = node.assignedSlot;
  251. } else if (!parentElement && rootNode !== node.ownerDocument) {
  252. node = rootNode.host;
  253. } else {
  254. node = parentElement;
  255. }
  256. }
  257. node = originalNode;
  258. }
  259. if (isNodeAttached(node)) {
  260. return !node.getClientRects().length;
  261. }
  262. if (displayCheck !== "legacy-full") {
  263. return true;
  264. }
  265. } else if (displayCheck === "non-zero-area") {
  266. return isZeroArea(node);
  267. }
  268. return false;
  269. };
  270. var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
  271. if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
  272. var parentNode = node.parentElement;
  273. while (parentNode) {
  274. if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
  275. for (var i3 = 0; i3 < parentNode.children.length; i3++) {
  276. var child = parentNode.children.item(i3);
  277. if (child.tagName === "LEGEND") {
  278. return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
  279. }
  280. }
  281. return true;
  282. }
  283. parentNode = parentNode.parentElement;
  284. }
  285. }
  286. return false;
  287. };
  288. var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
  289. if (node.disabled || isHiddenInput(node) || isHidden(node, options) || isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
  290. return false;
  291. }
  292. return true;
  293. };
  294. var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
  295. if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
  296. return false;
  297. }
  298. return true;
  299. };
  300. var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) {
  301. var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
  302. if (isNaN(tabIndex) || tabIndex >= 0) {
  303. return true;
  304. }
  305. return false;
  306. };
  307. var sortByOrder = function sortByOrder2(candidates) {
  308. var regularTabbables = [];
  309. var orderedTabbables = [];
  310. candidates.forEach(function(item, i3) {
  311. var isScope = !!item.scopeParent;
  312. var element = isScope ? item.scopeParent : item;
  313. var candidateTabindex = getTabindex(element, isScope);
  314. var elements = isScope ? sortByOrder2(item.candidates) : element;
  315. if (candidateTabindex === 0) {
  316. isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
  317. } else {
  318. orderedTabbables.push({
  319. documentOrder: i3,
  320. tabIndex: candidateTabindex,
  321. item,
  322. isScope,
  323. content: elements
  324. });
  325. }
  326. });
  327. return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
  328. sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
  329. return acc;
  330. }, []).concat(regularTabbables);
  331. };
  332. var tabbable = function tabbable2(el, options) {
  333. options = options || {};
  334. var candidates;
  335. if (options.getShadowRoot) {
  336. candidates = getCandidatesIteratively([el], options.includeContainer, {
  337. filter: isNodeMatchingSelectorTabbable.bind(null, options),
  338. flatten: false,
  339. getShadowRoot: options.getShadowRoot,
  340. shadowRootFilter: isValidShadowRootTabbable
  341. });
  342. } else {
  343. candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
  344. }
  345. return sortByOrder(candidates);
  346. };
  347. var focusable = function focusable2(el, options) {
  348. options = options || {};
  349. var candidates;
  350. if (options.getShadowRoot) {
  351. candidates = getCandidatesIteratively([el], options.includeContainer, {
  352. filter: isNodeMatchingSelectorFocusable.bind(null, options),
  353. flatten: true,
  354. getShadowRoot: options.getShadowRoot
  355. });
  356. } else {
  357. candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
  358. }
  359. return candidates;
  360. };
  361. var isTabbable = function isTabbable2(node, options) {
  362. options = options || {};
  363. if (!node) {
  364. throw new Error("No node provided");
  365. }
  366. if (matches.call(node, candidateSelector) === false) {
  367. return false;
  368. }
  369. return isNodeMatchingSelectorTabbable(options, node);
  370. };
  371. var focusableCandidateSelector = candidateSelectors.concat("iframe").join(",");
  372. var isFocusable = function isFocusable2(node, options) {
  373. options = options || {};
  374. if (!node) {
  375. throw new Error("No node provided");
  376. }
  377. if (matches.call(node, focusableCandidateSelector) === false) {
  378. return false;
  379. }
  380. return isNodeMatchingSelectorFocusable(options, node);
  381. };
  382. // node_modules/focus-trap/dist/focus-trap.esm.js
  383. function ownKeys(object, enumerableOnly) {
  384. var keys = Object.keys(object);
  385. if (Object.getOwnPropertySymbols) {
  386. var symbols = Object.getOwnPropertySymbols(object);
  387. enumerableOnly && (symbols = symbols.filter(function(sym) {
  388. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  389. })), keys.push.apply(keys, symbols);
  390. }
  391. return keys;
  392. }
  393. function _objectSpread2(target) {
  394. for (var i3 = 1; i3 < arguments.length; i3++) {
  395. var source = null != arguments[i3] ? arguments[i3] : {};
  396. i3 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
  397. _defineProperty(target, key, source[key]);
  398. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
  399. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  400. });
  401. }
  402. return target;
  403. }
  404. function _defineProperty(obj, key, value) {
  405. if (key in obj) {
  406. Object.defineProperty(obj, key, {
  407. value,
  408. enumerable: true,
  409. configurable: true,
  410. writable: true
  411. });
  412. } else {
  413. obj[key] = value;
  414. }
  415. return obj;
  416. }
  417. var activeFocusTraps = function() {
  418. var trapQueue = [];
  419. return {
  420. activateTrap: function activateTrap(trap) {
  421. if (trapQueue.length > 0) {
  422. var activeTrap = trapQueue[trapQueue.length - 1];
  423. if (activeTrap !== trap) {
  424. activeTrap.pause();
  425. }
  426. }
  427. var trapIndex = trapQueue.indexOf(trap);
  428. if (trapIndex === -1) {
  429. trapQueue.push(trap);
  430. } else {
  431. trapQueue.splice(trapIndex, 1);
  432. trapQueue.push(trap);
  433. }
  434. },
  435. deactivateTrap: function deactivateTrap(trap) {
  436. var trapIndex = trapQueue.indexOf(trap);
  437. if (trapIndex !== -1) {
  438. trapQueue.splice(trapIndex, 1);
  439. }
  440. if (trapQueue.length > 0) {
  441. trapQueue[trapQueue.length - 1].unpause();
  442. }
  443. }
  444. };
  445. }();
  446. var isSelectableInput = function isSelectableInput2(node) {
  447. return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
  448. };
  449. var isEscapeEvent = function isEscapeEvent2(e5) {
  450. return e5.key === "Escape" || e5.key === "Esc" || e5.keyCode === 27;
  451. };
  452. var isTabEvent = function isTabEvent2(e5) {
  453. return e5.key === "Tab" || e5.keyCode === 9;
  454. };
  455. var delay = function delay2(fn) {
  456. return setTimeout(fn, 0);
  457. };
  458. var findIndex = function findIndex2(arr, fn) {
  459. var idx = -1;
  460. arr.every(function(value, i3) {
  461. if (fn(value)) {
  462. idx = i3;
  463. return false;
  464. }
  465. return true;
  466. });
  467. return idx;
  468. };
  469. var valueOrHandler = function valueOrHandler2(value) {
  470. for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  471. params[_key - 1] = arguments[_key];
  472. }
  473. return typeof value === "function" ? value.apply(void 0, params) : value;
  474. };
  475. var getActualTarget = function getActualTarget2(event) {
  476. return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
  477. };
  478. var createFocusTrap = function createFocusTrap2(elements, userOptions) {
  479. var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
  480. var config = _objectSpread2({
  481. returnFocusOnDeactivate: true,
  482. escapeDeactivates: true,
  483. delayInitialFocus: true
  484. }, userOptions);
  485. var state = {
  486. containers: [],
  487. containerGroups: [],
  488. tabbableGroups: [],
  489. nodeFocusedBeforeActivation: null,
  490. mostRecentlyFocusedNode: null,
  491. active: false,
  492. paused: false,
  493. delayInitialFocusTimer: void 0
  494. };
  495. var trap;
  496. var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) {
  497. return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
  498. };
  499. var findContainerIndex = function findContainerIndex2(element) {
  500. return state.containerGroups.findIndex(function(_ref) {
  501. var container = _ref.container, tabbableNodes = _ref.tabbableNodes;
  502. return container.contains(element) || tabbableNodes.find(function(node) {
  503. return node === element;
  504. });
  505. });
  506. };
  507. var getNodeForOption = function getNodeForOption2(optionName) {
  508. var optionValue = config[optionName];
  509. if (typeof optionValue === "function") {
  510. for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  511. params[_key2 - 1] = arguments[_key2];
  512. }
  513. optionValue = optionValue.apply(void 0, params);
  514. }
  515. if (optionValue === true) {
  516. optionValue = void 0;
  517. }
  518. if (!optionValue) {
  519. if (optionValue === void 0 || optionValue === false) {
  520. return optionValue;
  521. }
  522. throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
  523. }
  524. var node = optionValue;
  525. if (typeof optionValue === "string") {
  526. node = doc.querySelector(optionValue);
  527. if (!node) {
  528. throw new Error("`".concat(optionName, "` as selector refers to no known node"));
  529. }
  530. }
  531. return node;
  532. };
  533. var getInitialFocusNode = function getInitialFocusNode2() {
  534. var node = getNodeForOption("initialFocus");
  535. if (node === false) {
  536. return false;
  537. }
  538. if (node === void 0) {
  539. if (findContainerIndex(doc.activeElement) >= 0) {
  540. node = doc.activeElement;
  541. } else {
  542. var firstTabbableGroup = state.tabbableGroups[0];
  543. var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
  544. node = firstTabbableNode || getNodeForOption("fallbackFocus");
  545. }
  546. }
  547. if (!node) {
  548. throw new Error("Your focus-trap needs to have at least one focusable element");
  549. }
  550. return node;
  551. };
  552. var updateTabbableNodes = function updateTabbableNodes2() {
  553. state.containerGroups = state.containers.map(function(container) {
  554. var tabbableNodes = tabbable(container, config.tabbableOptions);
  555. var focusableNodes = focusable(container, config.tabbableOptions);
  556. return {
  557. container,
  558. tabbableNodes,
  559. focusableNodes,
  560. firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
  561. lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
  562. nextTabbableNode: function nextTabbableNode(node) {
  563. var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
  564. var nodeIdx = focusableNodes.findIndex(function(n6) {
  565. return n6 === node;
  566. });
  567. if (nodeIdx < 0) {
  568. return void 0;
  569. }
  570. if (forward) {
  571. return focusableNodes.slice(nodeIdx + 1).find(function(n6) {
  572. return isTabbable(n6, config.tabbableOptions);
  573. });
  574. }
  575. return focusableNodes.slice(0, nodeIdx).reverse().find(function(n6) {
  576. return isTabbable(n6, config.tabbableOptions);
  577. });
  578. }
  579. };
  580. });
  581. state.tabbableGroups = state.containerGroups.filter(function(group) {
  582. return group.tabbableNodes.length > 0;
  583. });
  584. if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) {
  585. throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
  586. }
  587. };
  588. var tryFocus = function tryFocus2(node) {
  589. if (node === false) {
  590. return;
  591. }
  592. if (node === doc.activeElement) {
  593. return;
  594. }
  595. if (!node || !node.focus) {
  596. tryFocus2(getInitialFocusNode());
  597. return;
  598. }
  599. node.focus({
  600. preventScroll: !!config.preventScroll
  601. });
  602. state.mostRecentlyFocusedNode = node;
  603. if (isSelectableInput(node)) {
  604. node.select();
  605. }
  606. };
  607. var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) {
  608. var node = getNodeForOption("setReturnFocus", previousActiveElement);
  609. return node ? node : node === false ? false : previousActiveElement;
  610. };
  611. var checkPointerDown = function checkPointerDown2(e5) {
  612. var target = getActualTarget(e5);
  613. if (findContainerIndex(target) >= 0) {
  614. return;
  615. }
  616. if (valueOrHandler(config.clickOutsideDeactivates, e5)) {
  617. trap.deactivate({
  618. returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
  619. });
  620. return;
  621. }
  622. if (valueOrHandler(config.allowOutsideClick, e5)) {
  623. return;
  624. }
  625. e5.preventDefault();
  626. };
  627. var checkFocusIn = function checkFocusIn2(e5) {
  628. var target = getActualTarget(e5);
  629. var targetContained = findContainerIndex(target) >= 0;
  630. if (targetContained || target instanceof Document) {
  631. if (targetContained) {
  632. state.mostRecentlyFocusedNode = target;
  633. }
  634. } else {
  635. e5.stopImmediatePropagation();
  636. tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
  637. }
  638. };
  639. var checkTab = function checkTab2(e5) {
  640. var target = getActualTarget(e5);
  641. updateTabbableNodes();
  642. var destinationNode = null;
  643. if (state.tabbableGroups.length > 0) {
  644. var containerIndex = findContainerIndex(target);
  645. var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0;
  646. if (containerIndex < 0) {
  647. if (e5.shiftKey) {
  648. destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
  649. } else {
  650. destinationNode = state.tabbableGroups[0].firstTabbableNode;
  651. }
  652. } else if (e5.shiftKey) {
  653. var startOfGroupIndex = findIndex(state.tabbableGroups, function(_ref2) {
  654. var firstTabbableNode = _ref2.firstTabbableNode;
  655. return target === firstTabbableNode;
  656. });
  657. if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
  658. startOfGroupIndex = containerIndex;
  659. }
  660. if (startOfGroupIndex >= 0) {
  661. var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
  662. var destinationGroup = state.tabbableGroups[destinationGroupIndex];
  663. destinationNode = destinationGroup.lastTabbableNode;
  664. }
  665. } else {
  666. var lastOfGroupIndex = findIndex(state.tabbableGroups, function(_ref3) {
  667. var lastTabbableNode = _ref3.lastTabbableNode;
  668. return target === lastTabbableNode;
  669. });
  670. if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
  671. lastOfGroupIndex = containerIndex;
  672. }
  673. if (lastOfGroupIndex >= 0) {
  674. var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
  675. var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
  676. destinationNode = _destinationGroup.firstTabbableNode;
  677. }
  678. }
  679. } else {
  680. destinationNode = getNodeForOption("fallbackFocus");
  681. }
  682. if (destinationNode) {
  683. e5.preventDefault();
  684. tryFocus(destinationNode);
  685. }
  686. };
  687. var checkKey = function checkKey2(e5) {
  688. if (isEscapeEvent(e5) && valueOrHandler(config.escapeDeactivates, e5) !== false) {
  689. e5.preventDefault();
  690. trap.deactivate();
  691. return;
  692. }
  693. if (isTabEvent(e5)) {
  694. checkTab(e5);
  695. return;
  696. }
  697. };
  698. var checkClick = function checkClick2(e5) {
  699. var target = getActualTarget(e5);
  700. if (findContainerIndex(target) >= 0) {
  701. return;
  702. }
  703. if (valueOrHandler(config.clickOutsideDeactivates, e5)) {
  704. return;
  705. }
  706. if (valueOrHandler(config.allowOutsideClick, e5)) {
  707. return;
  708. }
  709. e5.preventDefault();
  710. e5.stopImmediatePropagation();
  711. };
  712. var addListeners = function addListeners2() {
  713. if (!state.active) {
  714. return;
  715. }
  716. activeFocusTraps.activateTrap(trap);
  717. state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() {
  718. tryFocus(getInitialFocusNode());
  719. }) : tryFocus(getInitialFocusNode());
  720. doc.addEventListener("focusin", checkFocusIn, true);
  721. doc.addEventListener("mousedown", checkPointerDown, {
  722. capture: true,
  723. passive: false
  724. });
  725. doc.addEventListener("touchstart", checkPointerDown, {
  726. capture: true,
  727. passive: false
  728. });
  729. doc.addEventListener("click", checkClick, {
  730. capture: true,
  731. passive: false
  732. });
  733. doc.addEventListener("keydown", checkKey, {
  734. capture: true,
  735. passive: false
  736. });
  737. return trap;
  738. };
  739. var removeListeners = function removeListeners2() {
  740. if (!state.active) {
  741. return;
  742. }
  743. doc.removeEventListener("focusin", checkFocusIn, true);
  744. doc.removeEventListener("mousedown", checkPointerDown, true);
  745. doc.removeEventListener("touchstart", checkPointerDown, true);
  746. doc.removeEventListener("click", checkClick, true);
  747. doc.removeEventListener("keydown", checkKey, true);
  748. return trap;
  749. };
  750. trap = {
  751. get active() {
  752. return state.active;
  753. },
  754. get paused() {
  755. return state.paused;
  756. },
  757. activate: function activate(activateOptions) {
  758. if (state.active) {
  759. return this;
  760. }
  761. var onActivate = getOption(activateOptions, "onActivate");
  762. var onPostActivate = getOption(activateOptions, "onPostActivate");
  763. var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
  764. if (!checkCanFocusTrap) {
  765. updateTabbableNodes();
  766. }
  767. state.active = true;
  768. state.paused = false;
  769. state.nodeFocusedBeforeActivation = doc.activeElement;
  770. if (onActivate) {
  771. onActivate();
  772. }
  773. var finishActivation = function finishActivation2() {
  774. if (checkCanFocusTrap) {
  775. updateTabbableNodes();
  776. }
  777. addListeners();
  778. if (onPostActivate) {
  779. onPostActivate();
  780. }
  781. };
  782. if (checkCanFocusTrap) {
  783. checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
  784. return this;
  785. }
  786. finishActivation();
  787. return this;
  788. },
  789. deactivate: function deactivate(deactivateOptions) {
  790. if (!state.active) {
  791. return this;
  792. }
  793. var options = _objectSpread2({
  794. onDeactivate: config.onDeactivate,
  795. onPostDeactivate: config.onPostDeactivate,
  796. checkCanReturnFocus: config.checkCanReturnFocus
  797. }, deactivateOptions);
  798. clearTimeout(state.delayInitialFocusTimer);
  799. state.delayInitialFocusTimer = void 0;
  800. removeListeners();
  801. state.active = false;
  802. state.paused = false;
  803. activeFocusTraps.deactivateTrap(trap);
  804. var onDeactivate = getOption(options, "onDeactivate");
  805. var onPostDeactivate = getOption(options, "onPostDeactivate");
  806. var checkCanReturnFocus = getOption(options, "checkCanReturnFocus");
  807. var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate");
  808. if (onDeactivate) {
  809. onDeactivate();
  810. }
  811. var finishDeactivation = function finishDeactivation2() {
  812. delay(function() {
  813. if (returnFocus) {
  814. tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
  815. }
  816. if (onPostDeactivate) {
  817. onPostDeactivate();
  818. }
  819. });
  820. };
  821. if (returnFocus && checkCanReturnFocus) {
  822. checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
  823. return this;
  824. }
  825. finishDeactivation();
  826. return this;
  827. },
  828. pause: function pause() {
  829. if (state.paused || !state.active) {
  830. return this;
  831. }
  832. state.paused = true;
  833. removeListeners();
  834. return this;
  835. },
  836. unpause: function unpause() {
  837. if (!state.paused || !state.active) {
  838. return this;
  839. }
  840. state.paused = false;
  841. updateTabbableNodes();
  842. addListeners();
  843. return this;
  844. },
  845. updateContainerElements: function updateContainerElements(containerElements) {
  846. var elementsAsArray = [].concat(containerElements).filter(Boolean);
  847. state.containers = elementsAsArray.map(function(element) {
  848. return typeof element === "string" ? doc.querySelector(element) : element;
  849. });
  850. if (state.active) {
  851. updateTabbableNodes();
  852. }
  853. return this;
  854. }
  855. };
  856. trap.updateContainerElements(elements);
  857. return trap;
  858. };
  859. // node_modules/@arcgis/core/identity/IdentityModal.js
  860. var l4 = { base: "esri-identity-modal", open: "esri-identity-modal--open", closed: "esri-identity-modal--closed", title: "esri-identity-modal__title", dialog: "esri-identity-modal__dialog", content: "esri-identity-modal__content", closeButton: "esri-identity-modal__close-button", iconClose: "esri-icon-close" };
  861. var p4 = class extends M {
  862. constructor(t4, e5) {
  863. super(t4, e5), this.container = document.createElement("div"), this.content = null, this.open = false, this._focusTrap = null, this._close = () => {
  864. this.open = false;
  865. }, document.body.appendChild(this.container), this.addHandles(l2(() => this.open, () => this._toggleFocusTrap()));
  866. }
  867. destroy() {
  868. this._destroyFocusTrap();
  869. }
  870. get title() {
  871. var _a;
  872. return (_a = this.messages) == null ? void 0 : _a.auth.signIn;
  873. }
  874. render() {
  875. const t4 = this.id, { open: e5, content: o, title: s8, messages: i3 } = this, r3 = e5 && !!o, n6 = { [l4.open]: r3, [l4.closed]: !r3 }, a2 = n4("button", { class: l4.closeButton, "aria-label": i3.close, title: i3.close, bind: this, onclick: this._close, type: "button" }, n4("span", { "aria-hidden": "true", class: l4.iconClose })), d2 = `${t4}_title`, p6 = `${t4}_content`, u2 = s8 ? n4("h1", { id: d2, class: l4.title }, s8) : null, m = r3 ? n4("div", { bind: this, class: l4.dialog, role: "dialog", "aria-labelledby": d2, "aria-describedby": p6, afterCreate: this._createFocusTrap }, a2, u2, this._renderContent(p6)) : null;
  876. return n4("div", { tabIndex: -1, class: this.classes(l4.base, n6) }, m);
  877. }
  878. _destroyFocusTrap() {
  879. var _a;
  880. (_a = this._focusTrap) == null ? void 0 : _a.deactivate({ onDeactivate: () => {
  881. } }), this._focusTrap = null;
  882. }
  883. _toggleFocusTrap() {
  884. const { _focusTrap: t4, open: e5 } = this;
  885. t4 && (e5 ? t4.activate() : t4.deactivate());
  886. }
  887. _createFocusTrap(t4) {
  888. this._destroyFocusTrap();
  889. const o = requestAnimationFrame(() => {
  890. this._focusTrap = createFocusTrap(t4, { initialFocus: "input", onDeactivate: this._close }), this._toggleFocusTrap();
  891. });
  892. this.addHandles(n(() => cancelAnimationFrame(o)));
  893. }
  894. _renderContent(t4) {
  895. const e5 = this.content;
  896. return "string" == typeof e5 ? n4("div", { class: l4.content, id: t4, innerHTML: e5 }) : e3(e5) ? n4("div", { class: l4.content, id: t4 }, e5.render()) : e5 instanceof HTMLElement ? n4("div", { class: l4.content, id: t4, bind: e5, afterCreate: this._attachToNode }) : null;
  897. }
  898. _attachToNode(t4) {
  899. const e5 = this;
  900. t4.appendChild(e5);
  901. }
  902. };
  903. e([y({ readOnly: true })], p4.prototype, "container", void 0), e([y()], p4.prototype, "content", void 0), e([y()], p4.prototype, "open", void 0), e([y(), e2("esri/t9n/common")], p4.prototype, "messages", void 0), e([y()], p4.prototype, "title", null), p4 = e([n2("esri.identity.IdentityModal")], p4);
  904. var u = p4;
  905. // node_modules/@arcgis/core/identity/OAuthCredential.js
  906. var t3 = "esriJSAPIOAuth";
  907. var e4 = class {
  908. constructor(t4, e5) {
  909. this.oAuthInfo = null, this.storage = null, this.appId = null, this.codeVerifier = null, this.expires = null, this.refreshToken = null, this.ssl = null, this.stateUID = null, this.token = null, this.userId = null, this.oAuthInfo = t4, this.storage = e5, this._init();
  910. }
  911. isValid() {
  912. let t4 = false;
  913. if (this.oAuthInfo && this.userId && (this.refreshToken || this.token)) {
  914. if (null == this.expires && this.refreshToken)
  915. t4 = true;
  916. else if (this.expires) {
  917. const e5 = Date.now();
  918. if (this.expires > e5) {
  919. (this.expires - e5) / 1e3 > 60 * this.oAuthInfo.minTimeUntilExpiration && (t4 = true);
  920. }
  921. }
  922. }
  923. return t4;
  924. }
  925. save() {
  926. if (!this.storage)
  927. return false;
  928. const e5 = this._load(), s8 = this.oAuthInfo;
  929. if (s8 && s8.authNamespace && s8.portalUrl) {
  930. let r3 = e5[s8.authNamespace];
  931. r3 || (r3 = e5[s8.authNamespace] = {}), this.appId || (this.appId = s8.appId), r3[s8.portalUrl] = { appId: this.appId, codeVerifier: this.codeVerifier, expires: this.expires, refreshToken: this.refreshToken, ssl: this.ssl, stateUID: this.stateUID, token: this.token, userId: this.userId };
  932. try {
  933. this.storage.setItem(t3, JSON.stringify(e5));
  934. } catch (i3) {
  935. return console.warn(i3), false;
  936. }
  937. return true;
  938. }
  939. return false;
  940. }
  941. destroy() {
  942. const e5 = this._load(), s8 = this.oAuthInfo;
  943. if (s8 && s8.appId && s8.portalUrl && (null == this.expires || this.expires > Date.now()) && (this.refreshToken || this.token)) {
  944. const t4 = s8.portalUrl.replace(/^http:/i, "https:") + "/sharing/rest/oauth2/revokeToken", e6 = new FormData();
  945. if (e6.append("f", "json"), e6.append("auth_token", this.refreshToken || this.token), e6.append("client_id", s8.appId), e6.append("token_type_hint", this.refreshToken ? "refresh_token" : "access_token"), "function" == typeof navigator.sendBeacon)
  946. navigator.sendBeacon(t4, e6);
  947. else {
  948. const s9 = new XMLHttpRequest();
  949. s9.open("POST", t4), s9.send(e6);
  950. }
  951. }
  952. if (s8 && s8.authNamespace && s8.portalUrl && this.storage) {
  953. const r3 = e5[s8.authNamespace];
  954. if (r3) {
  955. delete r3[s8.portalUrl];
  956. try {
  957. this.storage.setItem(t3, JSON.stringify(e5));
  958. } catch (i3) {
  959. console.log(i3);
  960. }
  961. }
  962. }
  963. s8 && (s8._oAuthCred = null, this.oAuthInfo = null);
  964. }
  965. _init() {
  966. const t4 = this._load(), e5 = this.oAuthInfo;
  967. if (e5 && e5.authNamespace && e5.portalUrl) {
  968. let s8 = t4[e5.authNamespace];
  969. s8 && (s8 = s8[e5.portalUrl], s8 && (this.appId = s8.appId, this.codeVerifier = s8.codeVerifier, this.expires = s8.expires, this.refreshToken = s8.refreshToken, this.ssl = s8.ssl, this.stateUID = s8.stateUID, this.token = s8.token, this.userId = s8.userId));
  970. }
  971. }
  972. _load() {
  973. let e5 = {};
  974. if (this.storage) {
  975. const i3 = this.storage.getItem(t3);
  976. if (i3)
  977. try {
  978. e5 = JSON.parse(i3);
  979. } catch (s8) {
  980. console.warn(s8);
  981. }
  982. }
  983. return e5;
  984. }
  985. };
  986. e4.prototype.declaredClass = "esri.identity.OAuthCredential";
  987. // node_modules/@arcgis/core/identity/OAuthInfo.js
  988. var p5;
  989. var s5 = p5 = class extends l {
  990. constructor(o) {
  991. super(o), this._oAuthCred = null, this.appId = null, this.authNamespace = "/", this.expiration = 20160, this.flowType = "auto", this.forceLogin = false, this.forceUserId = false, this.locale = null, this.minTimeUntilExpiration = 30, this.popup = false, this.popupCallbackUrl = "oauth-callback.html", this.popupWindowFeatures = "height=490,width=800,resizable,scrollbars,status", this.portalUrl = "https://www.arcgis.com", this.preserveUrlHash = false, this.userId = null;
  992. }
  993. clone() {
  994. return p5.fromJSON(this.toJSON());
  995. }
  996. };
  997. e([y({ json: { write: true } })], s5.prototype, "appId", void 0), e([y({ json: { write: true } })], s5.prototype, "authNamespace", void 0), e([y({ json: { write: true } })], s5.prototype, "expiration", void 0), e([y({ json: { write: true } })], s5.prototype, "flowType", void 0), e([y({ json: { write: true } })], s5.prototype, "forceLogin", void 0), e([y({ json: { write: true } })], s5.prototype, "forceUserId", void 0), e([y({ json: { write: true } })], s5.prototype, "locale", void 0), e([y({ json: { write: true } })], s5.prototype, "minTimeUntilExpiration", void 0), e([y({ json: { write: true } })], s5.prototype, "popup", void 0), e([y({ json: { write: true } })], s5.prototype, "popupCallbackUrl", void 0), e([y({ json: { write: true } })], s5.prototype, "popupWindowFeatures", void 0), e([y({ json: { write: true } })], s5.prototype, "portalUrl", void 0), e([y({ json: { write: true } })], s5.prototype, "preserveUrlHash", void 0), e([y({ json: { write: true } })], s5.prototype, "userId", void 0), s5 = p5 = e([n2("esri.identity.OAuthInfo")], s5);
  998. var i = s5;
  999. // node_modules/@arcgis/core/identity/ServerInfo.js
  1000. var s6 = class extends l {
  1001. constructor(o) {
  1002. super(o), this.adminTokenServiceUrl = null, this.currentVersion = null, this.hasPortal = null, this.hasServer = null, this.owningSystemUrl = null, this.owningTenant = null, this.server = null, this.shortLivedTokenValidity = null, this.tokenServiceUrl = null, this.webTierAuth = null;
  1003. }
  1004. };
  1005. e([y({ json: { write: true } })], s6.prototype, "adminTokenServiceUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "currentVersion", void 0), e([y({ json: { write: true } })], s6.prototype, "hasPortal", void 0), e([y({ json: { write: true } })], s6.prototype, "hasServer", void 0), e([y({ json: { write: true } })], s6.prototype, "owningSystemUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "owningTenant", void 0), e([y({ json: { write: true } })], s6.prototype, "server", void 0), e([y({ json: { write: true } })], s6.prototype, "shortLivedTokenValidity", void 0), e([y({ json: { write: true } })], s6.prototype, "tokenServiceUrl", void 0), e([y({ json: { write: true } })], s6.prototype, "webTierAuth", void 0), s6 = e([n2("esri.identity.ServerInfo")], s6);
  1006. var i2 = s6;
  1007. // node_modules/@arcgis/core/identity/IdentityManagerBase.js
  1008. var C = {};
  1009. var b = (e5) => {
  1010. const t4 = new y2(e5.owningSystemUrl).host, r3 = new y2(e5.server).host, s8 = /.+\.arcgis\.com$/i;
  1011. return s8.test(t4) && s8.test(r3);
  1012. };
  1013. var D2 = (e5, t4) => !!(b(e5) && t4 && t4.some((t5) => t5.test(e5.server)));
  1014. var q = null;
  1015. var j2 = null;
  1016. try {
  1017. q = window.localStorage, j2 = window.sessionStorage;
  1018. } catch {
  1019. }
  1020. var E = class extends n3 {
  1021. constructor() {
  1022. super(), this._portalConfig = globalThis.esriGeowConfig, this.serverInfos = [], this.oAuthInfos = [], this.credentials = [], this._soReqs = [], this._xoReqs = [], this._portals = [], this._defaultOAuthInfo = null, this._defaultTokenValidity = 60, this.dialog = null, this.formConstructor = d, this.tokenValidity = null, this.normalizeWebTierAuth = false, this._appOrigin = "null" !== window.origin ? window.origin : window.location.origin, this._appUrlObj = j(window.location.href), this._busy = null, this._rejectOnPersistedPageShow = false, this._oAuthLocationParams = null, this._gwTokenUrl = "/sharing/rest/generateToken", this._agsRest = "/rest/services", this._agsPortal = /\/sharing(\/|$)/i, this._agsAdmin = /(https?:\/\/[^\/]+\/[^\/]+)\/admin\/?(\/.*)?$/i, this._adminSvcs = /\/rest\/admin\/services(\/|$)/i, this._gwDomains = [{ regex: /^https?:\/\/www\.arcgis\.com/i, customBaseUrl: "maps.arcgis.com", tokenServiceUrl: "https://www.arcgis.com/sharing/rest/generateToken" }, { regex: /^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i, customBaseUrl: "mapsdev.arcgis.com", tokenServiceUrl: "https://dev.arcgis.com/sharing/rest/generateToken" }, { regex: /^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i, customBaseUrl: "mapsdevext.arcgis.com", tokenServiceUrl: "https://devext.arcgis.com/sharing/rest/generateToken" }, { regex: /^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i, customBaseUrl: "mapsqa.arcgis.com", tokenServiceUrl: "https://qaext.arcgis.com/sharing/rest/generateToken" }, { regex: /^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i, customBaseUrl: "maps.arcgis.com", tokenServiceUrl: "https://www.arcgis.com/sharing/rest/generateToken" }], this._legacyFed = [], this._regexSDirUrl = /http.+\/rest\/services\/?/gi, this._regexServerType = /(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer)).*/gi, this._gwUser = /http.+\/users\/([^\/]+)\/?.*/i, this._gwItem = /http.+\/items\/([^\/]+)\/?.*/i, this._gwGroup = /http.+\/groups\/([^\/]+)\/?.*/i, this._rePortalTokenSvc = /\/sharing(\/rest)?\/generatetoken/i, this._createDefaultOAuthInfo = true, this._hasTestedIfAppIsOnPortal = false, this._getOAuthLocationParams(), window.addEventListener("pageshow", (e5) => {
  1023. this._pageShowHandler(e5);
  1024. });
  1025. }
  1026. registerServers(e5) {
  1027. const t4 = this.serverInfos;
  1028. t4 ? (e5 = e5.filter((e6) => !this.findServerInfo(e6.server)), this.serverInfos = t4.concat(e5)) : this.serverInfos = e5, e5.forEach((e6) => {
  1029. e6.owningSystemUrl && this._portals.push(e6.owningSystemUrl), e6.hasPortal && this._portals.push(e6.server);
  1030. });
  1031. }
  1032. registerOAuthInfos(e5) {
  1033. const t4 = this.oAuthInfos;
  1034. if (t4) {
  1035. for (const r3 of e5) {
  1036. const e6 = this.findOAuthInfo(r3.portalUrl);
  1037. e6 && t4.splice(t4.indexOf(e6), 1);
  1038. }
  1039. this.oAuthInfos = t4.concat(e5);
  1040. } else
  1041. this.oAuthInfos = e5;
  1042. }
  1043. registerToken(e5) {
  1044. e5 = { ...e5 };
  1045. const t4 = this._sanitizeUrl(e5.server), r3 = this._isServerRsrc(t4);
  1046. let s8, i3 = this.findServerInfo(t4), o = true;
  1047. i3 || (i3 = new i2(), i3.server = this._getServerInstanceRoot(t4), r3 ? i3.hasServer = true : (i3.tokenServiceUrl = this._getTokenSvcUrl(t4), i3.hasPortal = true), this.registerServers([i3])), s8 = this._findCredential(t4), s8 ? (delete e5.server, Object.assign(s8, e5), o = false) : (s8 = new L2({ userId: e5.userId, server: i3.server, token: e5.token, expires: e5.expires, ssl: e5.ssl, scope: r3 ? "server" : "portal" }), s8.resources = [t4], this.credentials.push(s8)), s8.emitTokenChange(false), o || s8.refreshServerTokens();
  1048. }
  1049. toJSON() {
  1050. return p({ serverInfos: this.serverInfos.map((e5) => e5.toJSON()), oAuthInfos: this.oAuthInfos.map((e5) => e5.toJSON()), credentials: this.credentials.map((e5) => e5.toJSON()) });
  1051. }
  1052. initialize(e5) {
  1053. if (!e5)
  1054. return;
  1055. "string" == typeof e5 && (e5 = JSON.parse(e5));
  1056. const t4 = e5.serverInfos, r3 = e5.oAuthInfos, s8 = e5.credentials;
  1057. if (t4) {
  1058. const e6 = [];
  1059. t4.forEach((t5) => {
  1060. t5.server && t5.tokenServiceUrl && e6.push(t5.declaredClass ? t5 : new i2(t5));
  1061. }), e6.length && this.registerServers(e6);
  1062. }
  1063. if (r3) {
  1064. const e6 = [];
  1065. r3.forEach((t5) => {
  1066. t5.appId && e6.push(t5.declaredClass ? t5 : new i(t5));
  1067. }), e6.length && this.registerOAuthInfos(e6);
  1068. }
  1069. s8 && s8.forEach((e6) => {
  1070. e6.server && e6.token && e6.expires && e6.expires > Date.now() && ((e6 = e6.declaredClass ? e6 : new L2(e6)).emitTokenChange(), this.credentials.push(e6));
  1071. });
  1072. }
  1073. findServerInfo(e5) {
  1074. let t4;
  1075. e5 = this._sanitizeUrl(e5);
  1076. for (const r3 of this.serverInfos)
  1077. if (this._hasSameServerInstance(r3.server, e5)) {
  1078. t4 = r3;
  1079. break;
  1080. }
  1081. return t4;
  1082. }
  1083. findOAuthInfo(e5) {
  1084. let t4;
  1085. e5 = this._sanitizeUrl(e5);
  1086. for (const r3 of this.oAuthInfos)
  1087. if (this._hasSameServerInstance(r3.portalUrl, e5)) {
  1088. t4 = r3;
  1089. break;
  1090. }
  1091. return t4;
  1092. }
  1093. findCredential(e5, t4) {
  1094. if (!e5)
  1095. return;
  1096. let r3;
  1097. e5 = this._sanitizeUrl(e5);
  1098. const s8 = this._isServerRsrc(e5) ? "server" : "portal";
  1099. if (t4) {
  1100. for (const i3 of this.credentials)
  1101. if (this._hasSameServerInstance(i3.server, e5) && t4 === i3.userId && i3.scope === s8) {
  1102. r3 = i3;
  1103. break;
  1104. }
  1105. } else
  1106. for (const i3 of this.credentials)
  1107. if (this._hasSameServerInstance(i3.server, e5) && -1 !== this._getIdenticalSvcIdx(e5, i3) && i3.scope === s8) {
  1108. r3 = i3;
  1109. break;
  1110. }
  1111. return r3;
  1112. }
  1113. getCredential(e5, t4) {
  1114. let r3, s8, o = true;
  1115. t4 && (r3 = !!t4.token, s8 = t4.error, o = false !== t4.prompt), t4 = { ...t4 }, e5 = this._sanitizeUrl(e5);
  1116. const n6 = new AbortController(), a2 = D();
  1117. if (t4.signal && v(t4.signal, () => {
  1118. n6.abort();
  1119. }), v(n6, () => {
  1120. a2.reject(new s2("identity-manager:user-aborted", "ABORTED"));
  1121. }), p2(n6))
  1122. return a2.promise;
  1123. t4.signal = n6.signal;
  1124. const h = this._isAdminResource(e5), u2 = r3 ? this.findCredential(e5) : null;
  1125. let p6;
  1126. if (u2 && s8 && s8.details && 498 === s8.details.httpStatus)
  1127. u2.destroy();
  1128. else if (u2)
  1129. return p6 = new s2("identity-manager:not-authorized", "You are currently signed in as: '" + u2.userId + "'. You do not have access to this resource: " + e5, { error: s8 }), a2.reject(p6), a2.promise;
  1130. const f = this._findCredential(e5, t4);
  1131. if (f)
  1132. return a2.resolve(f), a2.promise;
  1133. let g = this.findServerInfo(e5);
  1134. if (g)
  1135. !g.hasServer && this._isServerRsrc(e5) && (g._restInfoPms = this._getTokenSvcUrl(e5), g.hasServer = true);
  1136. else {
  1137. const t5 = this._getTokenSvcUrl(e5);
  1138. if (!t5)
  1139. return p6 = new s2("identity-manager:unknown-resource", "Unknown resource - could not find token service endpoint."), a2.reject(p6), a2.promise;
  1140. g = new i2(), g.server = this._getServerInstanceRoot(e5), "string" == typeof t5 ? (g.tokenServiceUrl = t5, g.hasPortal = true) : (g._restInfoPms = t5, g.hasServer = true), this.registerServers([g]);
  1141. }
  1142. return g.hasPortal && void 0 === g._selfReq && (o || z(g.tokenServiceUrl, this._appOrigin) || this._gwDomains.some((e6) => e6.tokenServiceUrl === g.tokenServiceUrl)) && (g._selfReq = { owningTenant: t4 && t4.owningTenant, selfDfd: this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc, "/sharing/rest/portals/self"), e5) }), this._enqueue(e5, g, t4, a2, h);
  1143. }
  1144. getResourceName(e5) {
  1145. return this._isRESTService(e5) ? e5.replace(this._regexSDirUrl, "").replace(this._regexServerType, "") || "" : this._gwUser.test(e5) && e5.replace(this._gwUser, "$1") || this._gwItem.test(e5) && e5.replace(this._gwItem, "$1") || this._gwGroup.test(e5) && e5.replace(this._gwGroup, "$1") || "";
  1146. }
  1147. generateToken(e5, t4, r3) {
  1148. const o = this._rePortalTokenSvc.test(e5.tokenServiceUrl), n6 = new y2(this._appOrigin), a2 = e5.shortLivedTokenValidity;
  1149. let h, l5, c, d2, u2, p6, g, m;
  1150. t4 && (m = this.tokenValidity || a2 || this._defaultTokenValidity, m > a2 && a2 > 0 && (m = a2)), r3 && (h = r3.isAdmin, l5 = r3.serverUrl, c = r3.token, p6 = r3.signal, g = r3.ssl, e5.customParameters = r3.customParameters), h ? d2 = e5.adminTokenServiceUrl : (d2 = e5.tokenServiceUrl, u2 = new y2(d2.toLowerCase()), e5.webTierAuth && (r3 == null ? void 0 : r3.serverUrl) && !g && "http" === n6.scheme && (z(n6.uri, d2, true) || "https" === u2.scheme && n6.host === u2.host && "7080" === n6.port && "7443" === u2.port) && (d2 = d2.replace(/^https:/i, "http:").replace(/:7443/i, ":7080")));
  1151. const v3 = { query: { request: "getToken", username: t4 == null ? void 0 : t4.username, password: t4 == null ? void 0 : t4.password, serverUrl: l5, token: c, expiration: m, referer: h || o ? this._appOrigin : null, client: h ? "referer" : null, f: "json", ...e5.customParameters }, method: "post", authMode: "anonymous", useProxy: this._useProxy(e5, r3), signal: p6, ...r3 == null ? void 0 : r3.ioArgs };
  1152. o || (v3.withCredentials = false);
  1153. return U(d2, v3).then((r4) => {
  1154. const s8 = r4.data;
  1155. if (!s8 || !s8.token)
  1156. return new s2("identity-manager:authentication-failed", "Unable to generate token");
  1157. const o2 = e5.server;
  1158. return C[o2] || (C[o2] = {}), t4 && (C[o2][t4.username] = t4.password), s8.validity = m, s8;
  1159. });
  1160. }
  1161. isBusy() {
  1162. return !!this._busy;
  1163. }
  1164. checkSignInStatus(e5) {
  1165. return this.checkAppAccess(e5, "").then((e6) => e6.credential);
  1166. }
  1167. checkAppAccess(e5, t4, r3) {
  1168. let o = false;
  1169. return this.getCredential(e5, { prompt: false }).then((n6) => {
  1170. let a2;
  1171. const h = { f: "json" };
  1172. if ("portal" === n6.scope)
  1173. if (t4 && (this._doPortalSignIn(e5) || r3 && r3.force))
  1174. a2 = n6.server + "/sharing/rest/oauth2/validateAppAccess", h.client_id = t4;
  1175. else {
  1176. if (!n6.token)
  1177. return { credential: n6 };
  1178. a2 = n6.server + "/sharing/rest";
  1179. }
  1180. else {
  1181. if (!n6.token)
  1182. return { credential: n6 };
  1183. a2 = n6.server + "/rest/services";
  1184. }
  1185. return n6.token && (h.token = n6.token), U(a2, { query: h, authMode: "anonymous" }).then((e6) => {
  1186. if (false === e6.data.valid)
  1187. throw new s2("identity-manager:not-authorized", `You are currently signed in as: '${n6.userId}'.`, e6.data);
  1188. return o = !!e6.data.viewOnlyUserTypeApp, { credential: n6 };
  1189. }).catch((e6) => {
  1190. if ("identity-manager:not-authorized" === e6.name)
  1191. throw e6;
  1192. const t5 = e6.details && e6.details.httpStatus;
  1193. if (498 === t5)
  1194. throw n6.destroy(), new s2("identity-manager:not-authenticated", "User is not signed in.");
  1195. if (400 === t5)
  1196. throw new s2("identity-manager:invalid-request");
  1197. return { credential: n6 };
  1198. });
  1199. }).then((e6) => ({ credential: e6.credential, viewOnly: o }));
  1200. }
  1201. setOAuthResponseHash(e5) {
  1202. e5 && ("#" === e5.charAt(0) && (e5 = e5.substring(1)), this._processOAuthPopupParams(L(e5)));
  1203. }
  1204. setOAuthRedirectionHandler(e5) {
  1205. this._oAuthRedirectFunc = e5;
  1206. }
  1207. setProtocolErrorHandler(e5) {
  1208. this._protocolFunc = e5;
  1209. }
  1210. signIn(e5, t4, r3 = {}) {
  1211. const s8 = D(), o = () => {
  1212. var _a;
  1213. h == null ? void 0 : h.remove(), d2 == null ? void 0 : d2.remove(), p6 == null ? void 0 : p6.remove(), a2 == null ? void 0 : a2.destroy(), (_a = this.dialog) == null ? void 0 : _a.destroy(), this.dialog = a2 = h = d2 = p6 = null;
  1214. }, n6 = () => {
  1215. o(), this._oAuthDfd = null, s8.reject(new s2("identity-manager:user-aborted", "ABORTED"));
  1216. };
  1217. r3.signal && v(r3.signal, () => {
  1218. n6();
  1219. });
  1220. let a2 = new this.formConstructor();
  1221. a2.resource = this.getResourceName(e5), a2.server = t4.server, this.dialog = new u(), this.dialog.content = a2, this.dialog.open = true, this.emit("dialog-create");
  1222. let h = a2.on("cancel", n6), d2 = l2(() => this.dialog.open, n6), p6 = a2.on("submit", (e6) => {
  1223. this.generateToken(t4, e6, { isAdmin: r3.isAdmin, signal: r3.signal }).then((i3) => {
  1224. o();
  1225. const n7 = new L2({ userId: e6.username, server: t4.server, token: i3.token, expires: null != i3.expires ? Number(i3.expires) : null, ssl: !!i3.ssl, isAdmin: r3.isAdmin, validity: i3.validity });
  1226. s8.resolve(n7);
  1227. }).catch((e7) => {
  1228. a2.error = e7, a2.signingIn = false;
  1229. });
  1230. });
  1231. return s8.promise;
  1232. }
  1233. oAuthSignIn(e5, t4, r3, s8) {
  1234. this._oAuthDfd = D();
  1235. const o = this._oAuthDfd;
  1236. let n6;
  1237. (s8 == null ? void 0 : s8.signal) && v(s8.signal, () => {
  1238. const e6 = this._oAuthDfd && this._oAuthDfd.oAuthWin_;
  1239. e6 && !e6.closed ? e6.close() : this.dialog && f();
  1240. }), o.resUrl_ = e5, o.sinfo_ = t4, o.oinfo_ = r3;
  1241. const a2 = r3._oAuthCred;
  1242. if (a2.storage && ("authorization-code" === r3.flowType || "auto" === r3.flowType && !r3.popup && t4.currentVersion >= 8.4)) {
  1243. let e6 = crypto.getRandomValues(new Uint8Array(32));
  1244. n6 = Z(e6), a2.codeVerifier = n6, e6 = crypto.getRandomValues(new Uint8Array(32)), a2.stateUID = Z(e6), a2.save() || (a2.codeVerifier = n6 = null);
  1245. } else
  1246. a2.codeVerifier = null;
  1247. let h, d2, p6, _;
  1248. this._getCodeChallenge(n6).then((i3) => {
  1249. const o2 = !s8 || false !== s8.oAuthPopupConfirmation;
  1250. r3.popup && o2 ? (h = new this.formConstructor(), h.oAuthPrompt = true, h.server = t4.server, this.dialog = new u(), this.dialog.content = h, this.dialog.open = true, this.emit("dialog-create"), d2 = h.on("cancel", f), p6 = l2(() => this.dialog.open, f), _ = h.on("submit", () => {
  1251. g(), this._doOAuthSignIn(e5, t4, r3, i3);
  1252. })) : this._doOAuthSignIn(e5, t4, r3, i3);
  1253. });
  1254. const f = () => {
  1255. g(), this._oAuthDfd = null, o.reject(new s2("identity-manager:user-aborted", "ABORTED"));
  1256. }, g = () => {
  1257. var _a;
  1258. d2 == null ? void 0 : d2.remove(), p6 == null ? void 0 : p6.remove(), _ == null ? void 0 : _.remove(), h == null ? void 0 : h.destroy(), (_a = this.dialog) == null ? void 0 : _a.destroy(), this.dialog = null;
  1259. };
  1260. return o.promise;
  1261. }
  1262. destroyCredentials() {
  1263. if (this.credentials) {
  1264. this.credentials.slice().forEach((e5) => {
  1265. e5.destroy();
  1266. });
  1267. }
  1268. this.emit("credentials-destroy");
  1269. }
  1270. enablePostMessageAuth(e5 = "https://www.arcgis.com/sharing/rest") {
  1271. this._postMessageAuthHandle && this._postMessageAuthHandle.remove(), this._postMessageAuthHandle = r(window, "message", (t4) => {
  1272. var _a;
  1273. if ((t4.origin === this._appOrigin || t4.origin.endsWith(".arcgis.com")) && "arcgis:auth:requestCredential" === ((_a = t4.data) == null ? void 0 : _a.type)) {
  1274. const r3 = t4.source;
  1275. this.getCredential(e5).then((e6) => {
  1276. r3.postMessage({ type: "arcgis:auth:credential", credential: { expires: e6.expires, server: e6.server, ssl: e6.ssl, token: e6.token, userId: e6.userId } }, t4.origin);
  1277. }).catch((e6) => {
  1278. r3.postMessage({ type: "arcgis:auth:error", error: { name: e6.name, message: e6.message } }, t4.origin);
  1279. });
  1280. }
  1281. });
  1282. }
  1283. disablePostMessageAuth() {
  1284. this._postMessageAuthHandle && (this._postMessageAuthHandle.remove(), this._postMessageAuthHandle = null);
  1285. }
  1286. _getOAuthLocationParams() {
  1287. var _a, _b;
  1288. let e5 = window.location.hash;
  1289. if (e5) {
  1290. "#" === e5.charAt(0) && (e5 = e5.substring(1));
  1291. const t5 = L(e5);
  1292. let r3 = false;
  1293. if (t5.access_token && t5.expires_in && t5.state && t5.hasOwnProperty("username"))
  1294. try {
  1295. t5.state = JSON.parse(t5.state), t5.state.portalUrl && (this._oAuthLocationParams = t5, r3 = true);
  1296. } catch {
  1297. }
  1298. else if (t5.error && t5.error_description && (console.log("IdentityManager OAuth Error: ", t5.error, " - ", t5.error_description), "access_denied" === t5.error && (r3 = true, t5.state)))
  1299. try {
  1300. t5.state = JSON.parse(t5.state);
  1301. } catch {
  1302. }
  1303. r3 && (window.location.hash = ((_a = t5.state) == null ? void 0 : _a.hash) || "");
  1304. }
  1305. let t4 = window.location.search;
  1306. if (t4) {
  1307. "?" === t4.charAt(0) && (t4 = t4.substring(1));
  1308. const e6 = L(t4);
  1309. let r3 = false;
  1310. if (e6.code && e6.state)
  1311. try {
  1312. e6.state = JSON.parse(e6.state), e6.state.portalUrl && e6.state.uid && (this._oAuthLocationParams = e6, r3 = true);
  1313. } catch {
  1314. }
  1315. else if (e6.error && e6.error_description && (console.log("IdentityManager OAuth Error: ", e6.error, " - ", e6.error_description), "access_denied" === e6.error && (r3 = true, e6.state)))
  1316. try {
  1317. e6.state = JSON.parse(e6.state);
  1318. } catch {
  1319. }
  1320. if (r3) {
  1321. const t5 = { ...e6 };
  1322. ["code", "error", "error_description", "message_code", "persist", "state"].forEach((e7) => {
  1323. delete t5[e7];
  1324. });
  1325. const r4 = I(t5), s8 = window.location.pathname + (r4 ? `?${r4}` : "") + (((_b = e6.state) == null ? void 0 : _b.hash) || "");
  1326. window.history.replaceState(window.history.state, "", s8);
  1327. }
  1328. }
  1329. }
  1330. _getOAuthToken(e5, t4, r3, i3, o) {
  1331. return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/token`, { authMode: "anonymous", method: "post", query: i3 && o ? { grant_type: "authorization_code", code: t4, redirect_uri: i3, client_id: r3, code_verifier: o } : { grant_type: "refresh_token", refresh_token: t4, client_id: r3 } }).then((e6) => e6.data);
  1332. }
  1333. _getCodeChallenge(e5) {
  1334. if (e5 && globalThis.isSecureContext) {
  1335. const t4 = new TextEncoder().encode(e5);
  1336. return crypto.subtle.digest("SHA-256", t4).then((e6) => Z(new Uint8Array(e6)));
  1337. }
  1338. return Promise.resolve(null);
  1339. }
  1340. _pageShowHandler(e5) {
  1341. if (e5.persisted && this.isBusy() && this._rejectOnPersistedPageShow) {
  1342. const e6 = new s2("identity-manager:user-aborted", "ABORTED");
  1343. this._errbackFunc(e6);
  1344. }
  1345. }
  1346. _findCredential(e5, t4) {
  1347. let r3, s8, i3, o, n6 = -1;
  1348. const a2 = t4 && t4.token, h = t4 && t4.resource, l5 = this._isServerRsrc(e5) ? "server" : "portal", c = this.credentials.filter((t5) => this._hasSameServerInstance(t5.server, e5) && t5.scope === l5);
  1349. if (e5 = h || e5, c.length)
  1350. if (1 === c.length) {
  1351. if (r3 = c[0], i3 = this.findServerInfo(r3.server), s8 = i3 && i3.owningSystemUrl, o = s8 ? this.findCredential(s8, r3.userId) : void 0, n6 = this._getIdenticalSvcIdx(e5, r3), !a2)
  1352. return -1 === n6 && r3.resources.push(e5), this._addResource(e5, o), r3;
  1353. -1 !== n6 && (r3.resources.splice(n6, 1), this._removeResource(e5, o));
  1354. } else {
  1355. let t5, r4;
  1356. if (c.some((a3) => (r4 = this._getIdenticalSvcIdx(e5, a3), -1 !== r4 && (t5 = a3, i3 = this.findServerInfo(t5.server), s8 = i3 && i3.owningSystemUrl, o = s8 ? this.findCredential(s8, t5.userId) : void 0, n6 = r4, true))), a2)
  1357. t5 && (t5.resources.splice(n6, 1), this._removeResource(e5, o));
  1358. else if (t5)
  1359. return this._addResource(e5, o), t5;
  1360. }
  1361. }
  1362. _findOAuthInfo(e5) {
  1363. let t4 = this.findOAuthInfo(e5);
  1364. if (!t4) {
  1365. for (const r3 of this.oAuthInfos)
  1366. if (this._isIdProvider(r3.portalUrl, e5)) {
  1367. t4 = r3;
  1368. break;
  1369. }
  1370. }
  1371. return t4;
  1372. }
  1373. _addResource(e5, t4) {
  1374. t4 && -1 === this._getIdenticalSvcIdx(e5, t4) && t4.resources.push(e5);
  1375. }
  1376. _removeResource(e5, t4) {
  1377. let r3 = -1;
  1378. t4 && (r3 = this._getIdenticalSvcIdx(e5, t4), r3 > -1 && t4.resources.splice(r3, 1));
  1379. }
  1380. _useProxy(e5, t4) {
  1381. return t4 && t4.isAdmin && !z(e5.adminTokenServiceUrl, this._appOrigin) || !this._isPortalDomain(e5.tokenServiceUrl) && "10.1" === String(e5.currentVersion) && !z(e5.tokenServiceUrl, this._appOrigin);
  1382. }
  1383. _getOrigin(e5) {
  1384. const t4 = new y2(e5);
  1385. return t4.scheme + "://" + t4.host + (null != t4.port ? ":" + t4.port : "");
  1386. }
  1387. _getServerInstanceRoot(e5) {
  1388. const t4 = e5.toLowerCase();
  1389. let r3 = t4.indexOf(this._agsRest);
  1390. return -1 === r3 && this._isAdminResource(e5) && (r3 = this._agsAdmin.test(e5) ? e5.replace(this._agsAdmin, "$1").length : e5.search(this._adminSvcs)), -1 !== r3 || t2(t4) || (r3 = t4.indexOf("/sharing")), -1 === r3 && "/" === t4.substr(-1) && (r3 = t4.length - 1), r3 > -1 ? e5.substring(0, r3) : e5;
  1391. }
  1392. _hasSameServerInstance(e5, t4) {
  1393. return "/" === e5.substr(-1) && (e5 = e5.slice(0, -1)), e5 = e5.toLowerCase(), t4 = this._getServerInstanceRoot(t4).toLowerCase(), e5 = this._normalizeAGOLorgDomain(e5), t4 = this._normalizeAGOLorgDomain(t4), (e5 = e5.substr(e5.indexOf(":"))) === (t4 = t4.substr(t4.indexOf(":")));
  1394. }
  1395. _normalizeAGOLorgDomain(e5) {
  1396. const t4 = /^https?:\/\/(?:cdn|[a-z\d-]+\.maps)\.arcgis\.com/i, r3 = /^https?:\/\/(?:cdndev|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i, s8 = /^https?:\/\/(?:cdnqa|[a-z\d-]+\.mapsqa)\.arcgis\.com/i;
  1397. return t4.test(e5) ? e5 = e5.replace(t4, "https://www.arcgis.com") : r3.test(e5) ? e5 = e5.replace(r3, "https://devext.arcgis.com") : s8.test(e5) && (e5 = e5.replace(s8, "https://qaext.arcgis.com")), e5;
  1398. }
  1399. _sanitizeUrl(e5) {
  1400. const r3 = (s.request.proxyUrl || "").toLowerCase(), s8 = r3 ? e5.toLowerCase().indexOf(r3 + "?") : -1;
  1401. return -1 !== s8 && (e5 = e5.substring(s8 + r3.length + 1)), e5 = F(e5), j(e5).path;
  1402. }
  1403. _isRESTService(e5) {
  1404. return e5.includes(this._agsRest);
  1405. }
  1406. _isAdminResource(e5) {
  1407. return this._agsAdmin.test(e5) || this._adminSvcs.test(e5);
  1408. }
  1409. _isServerRsrc(e5) {
  1410. return this._isRESTService(e5) || this._isAdminResource(e5);
  1411. }
  1412. _isIdenticalService(e5, t4) {
  1413. let r3 = false;
  1414. if (this._isRESTService(e5) && this._isRESTService(t4)) {
  1415. const s8 = this._getSuffix(e5).toLowerCase(), i3 = this._getSuffix(t4).toLowerCase();
  1416. if (r3 = s8 === i3, !r3) {
  1417. const e6 = /(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;
  1418. r3 = s8.replace(e6, "$1") === i3.replace(e6, "$1");
  1419. }
  1420. } else
  1421. this._isAdminResource(e5) && this._isAdminResource(t4) ? r3 = true : this._isServerRsrc(e5) || this._isServerRsrc(t4) || !this._isPortalDomain(e5) || (r3 = true);
  1422. return r3;
  1423. }
  1424. _isPortalDomain(e5) {
  1425. const r3 = new y2(e5.toLowerCase()), s8 = this._portalConfig;
  1426. let i3 = this._gwDomains.some((e6) => e6.regex.test(r3.uri));
  1427. return !i3 && s8 && (i3 = this._hasSameServerInstance(this._getServerInstanceRoot(s8.restBaseUrl), r3.uri)), i3 || s.portalUrl && (i3 = z(r3, s.portalUrl, true)), i3 || (i3 = this._portals.some((e6) => this._hasSameServerInstance(e6, r3.uri))), i3 = i3 || this._agsPortal.test(r3.path), i3;
  1428. }
  1429. _isIdProvider(e5, t4) {
  1430. let r3 = -1, s8 = -1;
  1431. this._gwDomains.forEach((i4, o) => {
  1432. -1 === r3 && i4.regex.test(e5) && (r3 = o), -1 === s8 && i4.regex.test(t4) && (s8 = o);
  1433. });
  1434. let i3 = false;
  1435. if (r3 > -1 && s8 > -1 && (0 === r3 || 4 === r3 ? 0 !== s8 && 4 !== s8 || (i3 = true) : 1 === r3 ? 1 !== s8 && 2 !== s8 || (i3 = true) : 2 === r3 ? 2 === s8 && (i3 = true) : 3 === r3 && 3 === s8 && (i3 = true)), !i3) {
  1436. const r4 = this.findServerInfo(t4), s9 = r4 && r4.owningSystemUrl;
  1437. s9 && b(r4) && this._isPortalDomain(s9) && this._isIdProvider(e5, s9) && (i3 = true);
  1438. }
  1439. return i3;
  1440. }
  1441. _getIdenticalSvcIdx(e5, t4) {
  1442. let r3 = -1;
  1443. for (let s8 = 0; s8 < t4.resources.length; s8++) {
  1444. const i3 = t4.resources[s8];
  1445. if (this._isIdenticalService(e5, i3)) {
  1446. r3 = s8;
  1447. break;
  1448. }
  1449. }
  1450. return r3;
  1451. }
  1452. _getSuffix(e5) {
  1453. return e5.replace(this._regexSDirUrl, "").replace(this._regexServerType, "$1");
  1454. }
  1455. _getTokenSvcUrl(e5) {
  1456. let t4, r3, i3;
  1457. if (this._isRESTService(e5) || this._isAdminResource(e5)) {
  1458. const i4 = this._getServerInstanceRoot(e5);
  1459. return t4 = i4 + "/admin/generateToken", r3 = U(e5 = i4 + "/rest/info", { query: { f: "json" } }).then((e6) => e6.data), { adminUrl: t4, promise: r3 };
  1460. }
  1461. if (this._isPortalDomain(e5)) {
  1462. let t5 = "";
  1463. if (this._gwDomains.some((r4) => (r4.regex.test(e5) && (t5 = r4.tokenServiceUrl), !!t5)), t5 || this._portals.some((r4) => (this._hasSameServerInstance(r4, e5) && (t5 = r4 + this._gwTokenUrl), !!t5)), t5 || (i3 = e5.toLowerCase().indexOf("/sharing"), -1 !== i3 && (t5 = e5.substring(0, i3) + this._gwTokenUrl)), t5 || (t5 = this._getOrigin(e5) + this._gwTokenUrl), t5) {
  1464. const r4 = new y2(e5).port;
  1465. /^http:\/\//i.test(e5) && "7080" === r4 && (t5 = t5.replace(/:7080/i, ":7443")), t5 = t5.replace(/http:/i, "https:");
  1466. }
  1467. return t5;
  1468. }
  1469. if (e5.toLowerCase().includes("premium.arcgisonline.com"))
  1470. return "https://premium.arcgisonline.com/server/tokens";
  1471. }
  1472. _processOAuthResponseParams(e5, t4, r3) {
  1473. const s8 = t4._oAuthCred;
  1474. if (e5.code) {
  1475. const i4 = s8.codeVerifier;
  1476. return s8.codeVerifier = null, s8.stateUID = null, s8.save(), this._getOAuthToken(r3.server, e5.code, t4.appId, this._getRedirectURI(t4, true), i4).then((i5) => {
  1477. const o = new L2({ userId: i5.username, server: r3.server, token: i5.access_token, expires: Date.now() + 1e3 * i5.expires_in, ssl: i5.ssl, oAuthState: e5.state, _oAuthCred: s8 });
  1478. return t4.userId = o.userId, s8.storage = i5.persist ? q : j2, s8.refreshToken = i5.refresh_token, s8.token = null, s8.expires = i5.refresh_token_expires_in ? Date.now() + 1e3 * i5.refresh_token_expires_in : null, s8.userId = o.userId, s8.ssl = o.ssl, s8.save(), o;
  1479. });
  1480. }
  1481. const i3 = new L2({ userId: e5.username, server: r3.server, token: e5.access_token, expires: Date.now() + 1e3 * Number(e5.expires_in), ssl: "true" === e5.ssl, oAuthState: e5.state, _oAuthCred: s8 });
  1482. return t4.userId = i3.userId, s8.storage = e5.persist ? q : j2, s8.refreshToken = null, s8.token = i3.token, s8.expires = i3.expires, s8.userId = i3.userId, s8.ssl = i3.ssl, s8.save(), Promise.resolve(i3);
  1483. }
  1484. _processOAuthPopupParams(e5) {
  1485. var _a;
  1486. const t4 = this._oAuthDfd;
  1487. if (this._oAuthDfd = null, t4)
  1488. if (clearInterval(this._oAuthIntervalId), (_a = this._oAuthOnPopupHandle) == null ? void 0 : _a.remove(), e5.error) {
  1489. const r3 = "access_denied" === e5.error, s8 = new s2(r3 ? "identity-manager:user-aborted" : "identity-manager:authentication-failed", r3 ? "ABORTED" : "OAuth: " + e5.error + " - " + e5.error_description);
  1490. t4.reject(s8);
  1491. } else
  1492. this._processOAuthResponseParams(e5, t4.oinfo_, t4.sinfo_).then((e6) => {
  1493. t4.resolve(e6);
  1494. }).catch((e6) => {
  1495. t4.reject(e6);
  1496. });
  1497. }
  1498. _setOAuthResponseQueryString(e5) {
  1499. e5 && ("?" === e5.charAt(0) && (e5 = e5.substring(1)), this._processOAuthPopupParams(L(e5)));
  1500. }
  1501. _exchangeToken(e5, t4, r3) {
  1502. return U(`${e5}/sharing/rest/oauth2/exchangeToken`, { authMode: "anonymous", method: "post", query: { f: "json", client_id: t4, token: r3 } }).then((e6) => e6.data.token);
  1503. }
  1504. _getPlatformSelf(e5, t4) {
  1505. return e5 = e5.replace(/^http:/i, "https:"), U(`${e5}/sharing/rest/oauth2/platformSelf`, { authMode: "anonymous", headers: { "X-Esri-Auth-Client-Id": t4, "X-Esri-Auth-Redirect-Uri": window.location.href.replace(/#.*$/, "") }, method: "post", query: { f: "json", expiration: 30 }, withCredentials: true }).then((e6) => e6.data);
  1506. }
  1507. _getPortalSelf(e5, t4) {
  1508. let r3;
  1509. if (this._gwDomains.some((t5) => (t5.regex.test(e5) && (r3 = t5.customBaseUrl), !!r3)), r3)
  1510. return Promise.resolve({ allSSL: true, currentVersion: "8.4", customBaseUrl: r3, portalMode: "multitenant", supportsOAuth: true });
  1511. this._appOrigin.startsWith("https:") ? e5 = e5.replace(/^http:/i, "https:").replace(/:7080/i, ":7443") : /^http:/i.test(t4) && (e5 = e5.replace(/^https:/i, "http:").replace(/:7443/i, ":7080"));
  1512. return U(e5, { query: { f: "json" }, authMode: "anonymous", withCredentials: true }).then((e6) => e6.data);
  1513. }
  1514. _doPortalSignIn(e5) {
  1515. const t4 = this._portalConfig, r3 = window.location.href, s8 = this.findServerInfo(e5);
  1516. return !(!t4 && !this._isPortalDomain(r3) || !(s8 ? s8.hasPortal || s8.owningSystemUrl && this._isPortalDomain(s8.owningSystemUrl) : this._isPortalDomain(e5)) || !(this._isIdProvider(r3, e5) || t4 && (this._hasSameServerInstance(this._getServerInstanceRoot(t4.restBaseUrl), e5) || this._isIdProvider(t4.restBaseUrl, e5)) || z(r3, e5, true)));
  1517. }
  1518. _checkProtocol(e5, t4, r3, s8) {
  1519. let o = true;
  1520. const n6 = s8 ? t4.adminTokenServiceUrl : t4.tokenServiceUrl;
  1521. if (n6.trim().toLowerCase().startsWith("https:") && !this._appOrigin.startsWith("https:") && J(n6) && (o = !!this._protocolFunc && !!this._protocolFunc({ resourceUrl: e5, serverInfo: t4 }), !o)) {
  1522. r3(new s2("identity-manager:aborted", "Aborted the Sign-In process to avoid sending password over insecure connection."));
  1523. }
  1524. return o;
  1525. }
  1526. _enqueue(e5, t4, r3, s8, i3, o) {
  1527. return s8 || (s8 = D()), s8.resUrl_ = e5, s8.sinfo_ = t4, s8.options_ = r3, s8.admin_ = i3, s8.refresh_ = o, this._busy ? this._hasSameServerInstance(this._getServerInstanceRoot(e5), this._busy.resUrl_) ? (this._oAuthDfd && this._oAuthDfd.oAuthWin_ && this._oAuthDfd.oAuthWin_.focus(), this._soReqs.push(s8)) : this._xoReqs.push(s8) : this._doSignIn(s8), s8.promise;
  1528. }
  1529. _doSignIn(e5) {
  1530. this._busy = e5, this._rejectOnPersistedPageShow = false;
  1531. const t4 = (t5) => {
  1532. const r4 = e5.options_ && e5.options_.resource, s9 = e5.resUrl_, i3 = e5.refresh_;
  1533. let o2 = false;
  1534. this.credentials.includes(t5) || (i3 && this.credentials.includes(i3) ? (i3.userId = t5.userId, i3.token = t5.token, i3.expires = t5.expires, i3.validity = t5.validity, i3.ssl = t5.ssl, i3.creationTime = t5.creationTime, o2 = true, t5 = i3) : this.credentials.push(t5)), t5.resources || (t5.resources = []), t5.resources.includes(r4 || s9) || t5.resources.push(r4 || s9), t5.scope = this._isServerRsrc(s9) ? "server" : "portal", t5.emitTokenChange();
  1535. const n6 = this._soReqs, a3 = {};
  1536. this._soReqs = [], n6.forEach((e6) => {
  1537. if (!this._isIdenticalService(s9, e6.resUrl_)) {
  1538. const r5 = this._getSuffix(e6.resUrl_);
  1539. a3[r5] || (a3[r5] = true, t5.resources.push(e6.resUrl_));
  1540. }
  1541. }), e5.resolve(t5), n6.forEach((e6) => {
  1542. this._hasSameServerInstance(this._getServerInstanceRoot(s9), e6.resUrl_) ? e6.resolve(t5) : this._soReqs.push(e6);
  1543. }), this._busy = e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, o2 || this.emit("credential-create", { credential: t5 }), this._soReqs.length ? this._doSignIn(this._soReqs.shift()) : this._xoReqs.length && this._doSignIn(this._xoReqs.shift());
  1544. }, r3 = (t5) => {
  1545. e5.reject(t5), this._busy = e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, this._soReqs.length ? this._doSignIn(this._soReqs.shift()) : this._xoReqs.length && this._doSignIn(this._xoReqs.shift());
  1546. }, s8 = (o2, a3, h, l6) => {
  1547. var _a, _b, _c;
  1548. const d3 = e5.sinfo_, u2 = !e5.options_ || false !== e5.options_.prompt, p6 = d3.hasPortal && this._findOAuthInfo(e5.resUrl_);
  1549. let f, g;
  1550. if (o2)
  1551. t4(new L2({ userId: o2, server: d3.server, token: h || null, expires: null != l6 ? Number(l6) : null, ssl: !!a3 }));
  1552. else if (window !== window.parent && ((_a = this._appUrlObj.query) == null ? void 0 : _a["arcgis-auth-origin"]) && ((_b = this._appUrlObj.query) == null ? void 0 : _b["arcgis-auth-portal"]) && this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]), e5.resUrl_)) {
  1553. window.parent.postMessage({ type: "arcgis:auth:requestCredential" }, this._appUrlObj.query["arcgis-auth-origin"]);
  1554. const s9 = r(window, "message", (e6) => {
  1555. e6.source === window.parent && e6.data && ("arcgis:auth:credential" === e6.data.type ? (s9.remove(), e6.data.credential.expires < Date.now() ? r3(new s2("identity-manager:credential-request-failed", "Parent application's token has expired.")) : t4(new L2(e6.data.credential))) : "arcgis:auth:error" === e6.data.type && (s9.remove(), "tokenExpiredError" === e6.data.error.name ? r3(new s2("identity-manager:credential-request-failed", "Parent application's token has expired.")) : r3(s2.fromJSON(e6.data.error))));
  1556. });
  1557. v((_c = e5.options_) == null ? void 0 : _c.signal, () => {
  1558. s9.remove();
  1559. });
  1560. } else if (p6) {
  1561. let o3 = p6._oAuthCred;
  1562. if (!o3) {
  1563. const e6 = new e4(p6, q), t5 = new e4(p6, j2);
  1564. e6.isValid() && t5.isValid() ? e6.expires > t5.expires ? (o3 = e6, t5.destroy()) : (o3 = t5, e6.destroy()) : o3 = e6.isValid() ? e6 : t5, p6._oAuthCred = o3;
  1565. }
  1566. if (o3.isValid()) {
  1567. f = new L2({ userId: o3.userId, server: d3.server, token: o3.token, expires: o3.expires, ssl: o3.ssl, _oAuthCred: o3 });
  1568. const r4 = p6.appId !== o3.appId && this._doPortalSignIn(e5.resUrl_);
  1569. r4 || o3.refreshToken ? (e5._pendingDfd = o3.refreshToken ? this._getOAuthToken(d3.server, o3.refreshToken, o3.appId).then((e6) => (f.expires = Date.now() + 1e3 * e6.expires_in, f.token = e6.access_token, f)) : Promise.resolve(f), e5._pendingDfd.then((e6) => r4 ? this._exchangeToken(e6.server, p6.appId, e6.token).then((t5) => (e6.token = t5, e6)).catch(() => e6) : e6).then((e6) => {
  1570. t4(e6);
  1571. }).catch(() => {
  1572. o3 == null ? void 0 : o3.destroy(), s8();
  1573. })) : t4(f);
  1574. } else if (this._oAuthLocationParams && this._hasSameServerInstance(p6.portalUrl, this._oAuthLocationParams.state.portalUrl) && (this._oAuthLocationParams.access_token || this._oAuthLocationParams.code && this._oAuthLocationParams.state.uid === o3.stateUID && o3.codeVerifier)) {
  1575. const s9 = this._oAuthLocationParams;
  1576. this._oAuthLocationParams = null, e5._pendingDfd = this._processOAuthResponseParams(s9, p6, d3).then((e6) => {
  1577. t4(e6);
  1578. }).catch(r3);
  1579. } else {
  1580. const s9 = () => {
  1581. u2 ? e5._pendingDfd = this.oAuthSignIn(e5.resUrl_, d3, p6, e5.options_).then(t4, r3) : (g = new s2("identity-manager:not-authenticated", "User is not signed in."), r3(g));
  1582. };
  1583. this._doPortalSignIn(e5.resUrl_) ? e5._pendingDfd = this._getPlatformSelf(d3.server, p6.appId).then((e6) => {
  1584. z(e6.portalUrl, this._appOrigin, true) ? (f = new L2({ userId: e6.username, server: d3.server, expires: Date.now() + 1e3 * e6.expires_in, token: e6.token }), t4(f)) : s9();
  1585. }).catch(s9) : s9();
  1586. }
  1587. } else if (u2) {
  1588. if (this._checkProtocol(e5.resUrl_, d3, r3, e5.admin_)) {
  1589. let s9 = e5.options_;
  1590. e5.admin_ && (s9 = s9 || {}, s9.isAdmin = true), e5._pendingDfd = this.signIn(e5.resUrl_, d3, s9).then(t4, r3);
  1591. }
  1592. } else
  1593. g = new s2("identity-manager:not-authenticated", "User is not signed in."), r3(g);
  1594. }, o = () => {
  1595. const s9 = e5.sinfo_, i3 = s9.owningSystemUrl, o2 = e5.options_;
  1596. let n6, a3, h, l6;
  1597. if (o2 && (n6 = o2.token, a3 = o2.error, h = o2.prompt), l6 = this._findCredential(i3, { token: n6, resource: e5.resUrl_ }), !l6) {
  1598. for (const e6 of this.credentials)
  1599. if (this._isIdProvider(i3, e6.server)) {
  1600. l6 = e6;
  1601. break;
  1602. }
  1603. }
  1604. if (l6) {
  1605. const i4 = this.findCredential(e5.resUrl_, l6.userId);
  1606. if (i4)
  1607. t4(i4);
  1608. else if (D2(s9, this._legacyFed)) {
  1609. const e6 = l6.toJSON();
  1610. e6.server = s9.server, e6.resources = null, t4(new L2(e6));
  1611. } else {
  1612. (e5._pendingDfd = this.generateToken(this.findServerInfo(l6.server), null, { serverUrl: e5.resUrl_, token: l6.token, signal: e5.options_.signal, ssl: l6.ssl })).then((r4) => {
  1613. t4(new L2({ userId: l6 == null ? void 0 : l6.userId, server: s9.server, token: r4.token, expires: null != r4.expires ? Number(r4.expires) : null, ssl: !!r4.ssl, isAdmin: e5.admin_, validity: r4.validity }));
  1614. }, r3);
  1615. }
  1616. } else {
  1617. this._busy = null, n6 && (e5.options_.token = null);
  1618. (e5._pendingDfd = this.getCredential(i3.replace(/\/?$/, "/sharing"), { resource: e5.resUrl_, owningTenant: s9.owningTenant, signal: e5.options_.signal, token: n6, error: a3, prompt: h })).then(() => {
  1619. this._enqueue(e5.resUrl_, e5.sinfo_, e5.options_, e5, e5.admin_);
  1620. }, (t5) => {
  1621. e5.resUrl_ = e5.sinfo_ = e5.refresh_ = null, e5.reject(t5);
  1622. });
  1623. }
  1624. };
  1625. this._errbackFunc = r3;
  1626. const a2 = e5.sinfo_.owningSystemUrl, l5 = this._isServerRsrc(e5.resUrl_), d2 = e5.sinfo_._restInfoPms;
  1627. d2 ? d2.promise.then((t5) => {
  1628. var _a, _b;
  1629. const r4 = e5.sinfo_;
  1630. if (r4._restInfoPms) {
  1631. r4.adminTokenServiceUrl = r4._restInfoPms.adminUrl, r4._restInfoPms = null, r4.tokenServiceUrl = (_a = t("authInfo.tokenServicesUrl", t5) || t("authInfo.tokenServiceUrl", t5) || t("tokenServiceUrl", t5)) != null ? _a : null, r4.shortLivedTokenValidity = (_b = t("authInfo.shortLivedTokenValidity", t5)) != null ? _b : null, r4.currentVersion = t5.currentVersion, r4.owningTenant = t5.owningTenant;
  1632. const e6 = r4.owningSystemUrl = t5.owningSystemUrl;
  1633. e6 && this._portals.push(e6);
  1634. }
  1635. l5 && r4.owningSystemUrl ? o() : s8();
  1636. }, () => {
  1637. e5.sinfo_._restInfoPms = null;
  1638. const t5 = new s2("identity-manager:server-identification-failed", "Unknown resource - could not find token service endpoint.");
  1639. r3(t5);
  1640. }) : l5 && a2 ? o() : e5.sinfo_._selfReq ? e5.sinfo_._selfReq.selfDfd.then((t5) => {
  1641. const r4 = {};
  1642. let s9, i3, o2, n6;
  1643. return t5 && (s9 = t5.user && t5.user.username, r4.username = s9, r4.allSSL = t5.allSSL, i3 = t5.supportsOAuth, n6 = parseFloat(t5.currentVersion), "multitenant" === t5.portalMode && (o2 = t5.customBaseUrl), e5.sinfo_.currentVersion = n6), e5.sinfo_.webTierAuth = !!s9, s9 && this.normalizeWebTierAuth ? this.generateToken(e5.sinfo_, null, { ssl: r4.allSSL }).catch(() => null).then((e6) => (r4.portalToken = e6 && e6.token, r4.tokenExpiration = e6 && e6.expires, r4)) : !s9 && i3 && n6 >= 4.4 && !this._findOAuthInfo(e5.resUrl_) ? this._generateOAuthInfo({ portalUrl: e5.sinfo_.server, customBaseUrl: o2, owningTenant: e5.sinfo_._selfReq.owningTenant }).catch(() => null).then(() => r4) : r4;
  1644. }).catch(() => null).then((t5) => {
  1645. e5.sinfo_._selfReq = null, t5 ? s8(t5.username, t5.allSSL, t5.portalToken, t5.tokenExpiration) : s8();
  1646. }) : s8();
  1647. }
  1648. _generateOAuthInfo(e5) {
  1649. let t4, r3 = null, i3 = e5.portalUrl;
  1650. const o = e5.customBaseUrl, n6 = e5.owningTenant, a2 = !this._defaultOAuthInfo && this._createDefaultOAuthInfo && !this._hasTestedIfAppIsOnPortal;
  1651. if (a2) {
  1652. r3 = window.location.href;
  1653. let e6 = r3.indexOf("?");
  1654. e6 > -1 && (r3 = r3.slice(0, e6)), e6 = r3.search(/\/(apps|home)\//), r3 = e6 > -1 ? r3.slice(0, e6) : null;
  1655. }
  1656. return a2 && r3 ? (this._hasTestedIfAppIsOnPortal = true, t4 = U(r3 + "/sharing/rest", { query: { f: "json" } }).then(() => {
  1657. this._defaultOAuthInfo = new i({ appId: "arcgisonline", popupCallbackUrl: r3 + "/home/oauth-callback.html" });
  1658. })) : t4 = Promise.resolve(), t4.then(() => {
  1659. if (this._defaultOAuthInfo)
  1660. return i3 = i3.replace(/^http:/i, "https:"), U(i3 + "/sharing/rest/oauth2/validateRedirectUri", { query: { accountId: n6, client_id: this._defaultOAuthInfo.appId, redirect_uri: Q(this._defaultOAuthInfo.popupCallbackUrl), f: "json" } }).then((e6) => {
  1661. if (e6.data.valid) {
  1662. const t5 = this._defaultOAuthInfo.clone();
  1663. e6.data.urlKey && o ? t5.portalUrl = "https://" + e6.data.urlKey.toLowerCase() + "." + o : t5.portalUrl = i3, t5.popup = window !== window.top || !(z(i3, this._appOrigin) || this._gwDomains.some((e7) => e7.regex.test(i3) && e7.regex.test(this._appOrigin))), this.oAuthInfos.push(t5);
  1664. }
  1665. });
  1666. });
  1667. }
  1668. _doOAuthSignIn(e5, t4, r3, s8) {
  1669. const o = r3._oAuthCred, a2 = { portalUrl: r3.portalUrl };
  1670. !r3.popup && r3.preserveUrlHash && window.location.hash && (a2.hash = window.location.hash), o.stateUID && (a2.uid = o.stateUID);
  1671. const h = { client_id: r3.appId, response_type: o.codeVerifier ? "code" : "token", state: JSON.stringify(a2), expiration: r3.expiration, locale: r3.locale, redirect_uri: this._getRedirectURI(r3, !!o.codeVerifier) };
  1672. r3.forceLogin && (h.force_login = true), r3.forceUserId && r3.userId && (h.prepopulatedusername = r3.userId), !r3.popup && this._doPortalSignIn(e5) && (h.redirectToUserOrgUrl = true), o.codeVerifier && (h.code_challenge = s8 || o.codeVerifier, h.code_challenge_method = s8 ? "S256" : "plain");
  1673. const l5 = r3.portalUrl.replace(/^http:/i, "https:") + "/sharing/oauth2/authorize", c = l5 + "?" + I(h);
  1674. if (r3.popup) {
  1675. const e6 = window.open(c, "esriJSAPIOAuth", r3.popupWindowFeatures);
  1676. if (e6)
  1677. e6.focus(), this._oAuthDfd.oAuthWin_ = e6, this._oAuthIntervalId = setInterval(() => {
  1678. if (e6.closed) {
  1679. clearInterval(this._oAuthIntervalId), this._oAuthOnPopupHandle.remove();
  1680. const e7 = this._oAuthDfd;
  1681. if (e7) {
  1682. const t5 = new s2("identity-manager:user-aborted", "ABORTED");
  1683. e7.reject(t5);
  1684. }
  1685. }
  1686. }, 500), this._oAuthOnPopupHandle = r(window, ["arcgis:auth:hash", "arcgis:auth:location:search"], (e7) => {
  1687. "arcgis:auth:hash" === e7.type ? this.setOAuthResponseHash(e7.detail) : this._setOAuthResponseQueryString(e7.detail);
  1688. });
  1689. else {
  1690. const e7 = new s2("identity-manager:popup-blocked", "ABORTED");
  1691. this._oAuthDfd.reject(e7);
  1692. }
  1693. } else
  1694. this._rejectOnPersistedPageShow = true, this._oAuthRedirectFunc ? this._oAuthRedirectFunc({ authorizeParams: h, authorizeUrl: l5, resourceUrl: e5, serverInfo: t4, oAuthInfo: r3 }) : window.location.href = c;
  1695. }
  1696. _getRedirectURI(e5, t4) {
  1697. const r3 = window.location.href.replace(/#.*$/, "");
  1698. if (e5.popup)
  1699. return Q(e5.popupCallbackUrl);
  1700. if (t4) {
  1701. const e6 = j(r3);
  1702. return e6.query && ["code", "error", "error_description", "message_code", "persist", "state"].forEach((t5) => {
  1703. delete e6.query[t5];
  1704. }), Bt(e6.path, e6.query);
  1705. }
  1706. return r3;
  1707. }
  1708. };
  1709. E.prototype.declaredClass = "esri.identity.IdentityManagerBase";
  1710. var L2 = class extends n3.EventedAccessor {
  1711. constructor(e5) {
  1712. super(e5), this._oAuthCred = null, this.tokenRefreshBuffer = 2, e5 && e5._oAuthCred && (this._oAuthCred = e5._oAuthCred);
  1713. }
  1714. initialize() {
  1715. this.resources = this.resources || [], null == this.creationTime && (this.creationTime = Date.now());
  1716. }
  1717. refreshToken() {
  1718. const e5 = s4.findServerInfo(this.server), t4 = e5 && e5.owningSystemUrl, s8 = !!t4 && "server" === this.scope, i3 = s8 && D2(e5, s4._legacyFed), o = e5.webTierAuth, n6 = o && s4.normalizeWebTierAuth, a2 = C[this.server], h = a2 && a2[this.userId];
  1719. let l5, c = this.resources && this.resources[0], d2 = s8 ? s4.findServerInfo(t4) : null, u2 = { username: this.userId, password: h };
  1720. if (o && !n6)
  1721. return;
  1722. s8 && !d2 && s4.serverInfos.some((e6) => (s4._isIdProvider(t4, e6.server) && (d2 = e6), !!d2));
  1723. const p6 = d2 ? s4.findCredential(d2.server, this.userId) : null;
  1724. if (!s8 || p6) {
  1725. if (!i3) {
  1726. if (s8)
  1727. l5 = { serverUrl: c, token: p6 && p6.token, ssl: p6 && p6.ssl };
  1728. else if (n6)
  1729. u2 = null, l5 = { ssl: this.ssl };
  1730. else {
  1731. if (!h) {
  1732. let t5;
  1733. return c && (c = s4._sanitizeUrl(c), this._enqueued = 1, t5 = s4._enqueue(c, e5, null, null, this.isAdmin, this), t5.then(() => {
  1734. this._enqueued = 0, this.refreshServerTokens();
  1735. }).catch(() => {
  1736. this._enqueued = 0;
  1737. })), t5;
  1738. }
  1739. this.isAdmin && (l5 = { isAdmin: true });
  1740. }
  1741. return s4.generateToken(s8 ? d2 : e5, s8 ? null : u2, l5).then((e6) => {
  1742. this.token = e6.token, this.expires = null != e6.expires ? Number(e6.expires) : null, this.creationTime = Date.now(), this.validity = e6.validity, this.emitTokenChange(), this.refreshServerTokens();
  1743. }).catch(() => {
  1744. });
  1745. }
  1746. p6 == null ? void 0 : p6.refreshToken();
  1747. }
  1748. }
  1749. refreshServerTokens() {
  1750. "portal" === this.scope && s4.credentials.forEach((e5) => {
  1751. const t4 = s4.findServerInfo(e5.server), s8 = t4 && t4.owningSystemUrl;
  1752. e5 !== this && e5.userId === this.userId && s8 && "server" === e5.scope && (s4._hasSameServerInstance(this.server, s8) || s4._isIdProvider(s8, this.server)) && (D2(t4, s4._legacyFed) ? (e5.token = this.token, e5.expires = this.expires, e5.creationTime = this.creationTime, e5.validity = this.validity, e5.emitTokenChange()) : e5.refreshToken());
  1753. });
  1754. }
  1755. emitTokenChange(e5) {
  1756. clearTimeout(this._refreshTimer);
  1757. const t4 = this.server && s4.findServerInfo(this.server), s8 = t4 && t4.owningSystemUrl, i3 = s8 && s4.findServerInfo(s8);
  1758. false === e5 || s8 && "portal" !== this.scope && (!i3 || !i3.webTierAuth || s4.normalizeWebTierAuth) || null == this.expires && null == this.validity || this._startRefreshTimer(), this.emit("token-change");
  1759. }
  1760. destroy() {
  1761. this.userId = this.server = this.token = this.expires = this.validity = this.resources = this.creationTime = null, this._oAuthCred && (this._oAuthCred.destroy(), this._oAuthCred = null);
  1762. const e5 = s4.credentials.indexOf(this);
  1763. e5 > -1 && s4.credentials.splice(e5, 1), this.emitTokenChange(), this.emit("destroy");
  1764. }
  1765. toJSON() {
  1766. const e5 = p({ userId: this.userId, server: this.server, token: this.token, expires: this.expires, validity: this.validity, ssl: this.ssl, isAdmin: this.isAdmin, creationTime: this.creationTime, scope: this.scope }), t4 = this.resources;
  1767. return t4 && t4.length > 0 && (e5.resources = t4.slice()), e5;
  1768. }
  1769. _startRefreshTimer() {
  1770. clearTimeout(this._refreshTimer);
  1771. const e5 = 6e4 * this.tokenRefreshBuffer, t4 = 2 ** 31 - 1;
  1772. let r3 = (this.validity ? this.creationTime + 6e4 * this.validity : this.expires) - Date.now();
  1773. r3 < 0 ? r3 = 0 : r3 > t4 && (r3 = t4), this._refreshTimer = setTimeout(this.refreshToken.bind(this), r3 > e5 ? r3 - e5 : r3);
  1774. }
  1775. };
  1776. e([y()], L2.prototype, "creationTime", void 0), e([y()], L2.prototype, "expires", void 0), e([y()], L2.prototype, "isAdmin", void 0), e([y()], L2.prototype, "oAuthState", void 0), e([y()], L2.prototype, "resources", void 0), e([y()], L2.prototype, "scope", void 0), e([y()], L2.prototype, "server", void 0), e([y()], L2.prototype, "ssl", void 0), e([y()], L2.prototype, "token", void 0), e([y()], L2.prototype, "tokenRefreshBuffer", void 0), e([y()], L2.prototype, "userId", void 0), e([y()], L2.prototype, "validity", void 0), L2 = e([n2("esri.identity.Credential")], L2);
  1777. // node_modules/@arcgis/core/identity/IdentityManager.js
  1778. var r2 = class extends E {
  1779. };
  1780. r2.prototype.declaredClass = "esri.identity.IdentityManager";
  1781. var s7 = new r2();
  1782. n5(s7);
  1783. export {
  1784. s7 as default
  1785. };
  1786. /*!
  1787. * focus-trap 7.0.0
  1788. * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
  1789. */
  1790. /*!
  1791. * tabbable 6.0.1
  1792. * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
  1793. */
  1794. //# sourceMappingURL=IdentityManager-RSGL7L3S.js.map