IdentityManager-CNNYIJFK.js 85 KB

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