/*
          Atlassian's React app will place itself below our elements when it changes, i.e.
          when asking for MFA prompt.To handle this, we need to move elements after the React app has
          done stuff. See KSE-3324 for example.
          */

/*
  options.target         - name of the target object
  options.global         - target is the global object
  options.stat           - export as static methods of target
  options.proto          - export as prototype methods of target
  options.real           - real prototype method for the `pure` version
  options.forced         - export even if the native feature is available
  options.bind           - bind methods to the target, required for the `pure` version
  options.wrap           - wrap constructors to preventing global pollution, required for the `pure` version
  options.unsafe         - use the simple assignment of property instead of delete + defineProperty
  options.sham           - add a flag to not completely full polyfills
  options.enumerable     - export as enumerable property
  options.dontCallGetSet - prevent calling a getter on target
  options.name           - the .name of the function if it does not match the key
*/

/* , ...args */

/* , ...arguments */

/* , endPosition = @length */

/* , fromIndex = 0 */

/* , position = 0 */

/* , thisArg */

/* .LoginPageState */

/* .getAtlassianCannotLoginLink */

/* .getAtlassianLoginForm */

/* .getAtlassianLoginPageTraditionalLoginErrorMessage */

/* .getAtlassianMfaPrompt */

/* .getAtlassianTitle */

/* .getCannotLoginFooter */

/* .getKssoLoginPage */

/* .getKssoTraditionalLoginErrorMessage */

/* .getModifyLanguageButton */

/* .getRedirectIndicator */

/* .getUseSsoButtonContainer */

/* LoginPageState */

/* binding */

/* empty */

/* eslint-disable @typescript-eslint/no-unused-vars */

/* eslint-disable es/no-array-prototype-indexof -- required for testing */

/* eslint-disable es/no-array-prototype-keys -- safe */

/* eslint-disable es/no-object-getownpropertynames -- safe */

/* eslint-disable es/no-symbol -- required for testing */

/* eslint-disable es/no-symbol -- safe */

/* eslint-disable no-proto -- safe */

/* eslint-disable no-self-assign -- prototype methods protection */

/* eslint-enable no-self-assign -- prototype methods protection */

/* getAtlassianLoginButton */

/* getAtlassianLoginForm */

/* getAtlassianTraditionalLoginDisabledMessage */

/* getAtlassianUsernameInput */

/* getIdpOrgName */

/* getKssoUsernameInput */

/* getManualRedirectContinueButton */

/* getPasswordInput */

/* getUseSsoButton */

/* getUseSsoButtonContainer */

/* global AJS, height, gadgets, prepareTarget */

/* global ActiveXObject -- old IE, WSH */

/* global Bun, Deno -- detection */

/* harmony export */

/* harmony import */

/* hideEverythingButRedirect */

/* ignore */

/* loginState */

/* toggleTraditionalLoginWarningBoxes */

/* unused harmony exports toggleKssoTraditionalLoginWarningBox, toggleAtlassianTraditionalLoginWarningBox, toggleUseSsoButton */

/* useAtlassianLoginPage */

/* useKssoLoginPage */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */

/*#__PURE__*/

/**
 * This is used to update Atlassian's React app to have the correct username during the
 * Manual redirect -> Cancel -> Username/password login flow
 */

/******/

/***/

//   https://github.com/zloirock/core-js/issues/1128

//   https://github.com/zloirock/core-js/issues/1130

// "Continue" should always be available if manual redirect is available

// "Log in with SSO" should only be available if an IdP can be selected or if manual redirect is available

// (for example, `DOMQuad` and similar in FF41-)

// 2 ** 53 - 1 == 9007199254740991

// 25.4.3.1 Promise(executor)

// @ts-ignore

// Array#includes uses SameValueZero equality algorithm

// Array#indexOf ignores holes, Array#includes - not

// Array.prototype[@@unscopables]

// Avoid NodeJS experimental warning

// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`

// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should

// Bun / IE9- setInterval additional parameters fix

// Bun / IE9- setTimeout additional parameters fix

// CONCATENATED MODULE: ./src/main/frontend/src/saml-login/src/helper-functions/business-logic.ts

// CONCATENATED MODULE: ./src/main/frontend/src/saml-login/src/helper-functions/setup.ts

// CONCATENATED MODULE: ./src/main/frontend/src/saml-login/src/helper-functions/utility.ts

// CONCATENATED MODULE: ./src/main/frontend/src/saml-login/src/index.ts

// CONCATENATED MODULE: ./src/main/frontend/src/saml-login/src/initialize-login-page-script.ts

// Chrome 38 Symbol has incorrect toString conversion

// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances

// Deno throws a ReferenceError on `location` access without `--location` flag

// Detect IE8's incomplete defineProperty implementation

// Detect correctness of subclassing with @@species support

// Don't enum bug & hidden keys

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.description.js

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.symbol.js

// EXTERNAL MODULE: ./src/main/frontend/src/saml-login/src/helper-functions/toggle-login-pages.ts

// FF44- legacy iterators case

// FIXME: Rename fields into better names when saml-legacy-login.ts is no longer in use.

// Fallback redirect -> redirect if only a single IdP or if useIdpPriority is active

// Function instances `.name` property

// Go to Atlassian login page unless user is blocked from traditional login.

// Helper for a popular repeating case of the spec:

// IE8 returns string on undefined

// IE8- don't enum bug keys

// IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix

// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).

// If we have more than zero matches, fallback IdP should not be used.

// JSON[@@toStringTag] property

// Let integer be ? ToInteger(index).

// MS Edge converts symbol values to JSON as {}

// Math[@@toStringTag] property

// Move traditional login prevented message to the top of the form

// Nashorn bug:

// No fallback redirect

// No visible IdP and no manual redirect. KSSO's login page cannot do anything so use Atlassian's,

// Node.js 0.8-

// Node.js 0.9+ & IE10+ has setImmediate, otherwise:

// Only state transition from Atlassian Login Page is clicking "Log in with SSO"-button

// Primary case -> Check if automatic redirection should happen

// Primary case: Username matches an IdP -> Redirect to first element in matches

// Promise.resolve without an argument throws an error in LG WebOS 2

// Safari 12 bug

// Safari 8 has buggy iterators w/o `next`

// Set @@toStringTag to native iterators

// TODO: Remove from `core-js@4`

// TODO: Remove this module from `core-js@4` since it's split to modules listed below

// Thanks to IE8 for its funny defineProperty

// The only time we don't want to initialize as KSSO login page is handled above

// Unhandled rejections tracking support, NodeJS Promise without it fails @@species test

// V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables

// V8 ~ Chrome 36-

// V8 ~ Chrome 45- bug

// WSH

// We can't detect it synchronously, so just check versions

// We can't use @@species feature detection in V8 since it causes

// We can't use this feature detection in V8 since it causes

// We need Promise#{ catch, finally } in the pure version for preventing prototype pollution

// Works with __proto__ only. Old v8 can't work with null proto objects.

// `%ArrayIteratorPrototype%.next` method

// `%IteratorPrototype%[@@iterator]()` method

// `%StringIteratorPrototype%.next` method

// `Array.prototype.entries` method

// `Array.prototype.every` method

// `Array.prototype.filterReject` method

// `Array.prototype.filter` method

// `Array.prototype.findIndex` method

// `Array.prototype.find` method

// `Array.prototype.forEach` method

// `Array.prototype.includes` method

// `Array.prototype.indexOf` method

// `Array.prototype.keys` method

// `Array.prototype.map` method

// `Array.prototype.reverse` method

// `Array.prototype.some` method

// `Array.prototype.values` method

// `Array.prototype[@@iterator]` method

// `ArraySpeciesCreate` abstract operation

// `Assert: IsCallable(argument) is true`

// `Assert: IsConstructor(argument) is true`

// `Assert: Type(argument) is Object`

// `CreateArrayIterator` internal method

// `CreateIterResultObject` abstract operation

// `Function#toString` throws on some built-it function in some legacy engines

// `Function.prototype.bind` method

// `Function.prototype.bind` method implementation

// `GetMethod` abstract operation

// `HasOwnProperty` abstract operation

// `IsArray` abstract operation

// `IsCallable` abstract operation

// `IsConstructor` abstract operation

// `IsRegExp` abstract operation

// `JSON.stringify` method

// `LengthOfArrayLike` abstract operation

// `Math.trunc` method

// `NewPromiseCapability` abstract operation

// `Object.create` method

// `Object.defineProperties` method

// `Object.defineProperty` method

// `Object.getOwnPropertyDescriptor` method

// `Object.getOwnPropertyNames` method

// `Object.getOwnPropertySymbols` method

// `Object.getPrototypeOf` method

// `Object.keys` method

// `Object.prototype.propertyIsEnumerable` method implementation

// `Object.prototype.toString` method

// `Object.prototype.toString` method implementation

// `Object.setPrototypeOf` method

// `OrdinaryToPrimitive` abstract operation

// `Promise.all` method

// `Promise.prototype.catch` method

// `Promise.prototype.then` method

// `Promise.race` method

// `Promise.reject` method

// `Promise.resolve` method

// `Promise` constructor

// `RequireObjectCoercible` abstract operation

// `SpeciesConstructor` abstract operation

// `String.prototype.at` method

// `String.prototype.codePointAt` method

// `String.prototype.endsWith` method

// `String.prototype.includes` method

// `String.prototype.startsWith` method

// `String.prototype.trim` method

// `String.prototype.{ trimLeft, trimStart }` methods

// `String.prototype.{ trimRight, trimEnd }` methods

// `String.prototype[@@iterator]` method

// `Symbol.asyncIterator` well-known symbol

// `Symbol.for` method

// `Symbol.iterator` well-known symbol

// `Symbol.keyFor` method

// `Symbol.prototype.description` getter

// `Symbol.prototype[@@toPrimitive]` method

// `Symbol.prototype[@@toStringTag]` property

// `Symbol.toStringTag` well-known symbol

// `Symbol` constructor

// `ToIntegerOrInfinity` abstract operation

// `ToLength` abstract operation

// `ToObject` abstract operation

// `ToPrimitive` abstract operation

// `ToPropertyKey` abstract operation

// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances

// `webpack` dev server bug on IE global methods - use bind(fn, global)

// a part of `ArraySpeciesCreate` abstract operation

// a string of all valid unicode whitespaces

// add "__proto__" for Object.getPrototypeOf polyfill

// add a flag to not completely full polyfills

// add a key to Array.prototype[@@unscopables]

// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative

// all object keys, includes non-enumerable and symbols

// also except WebOS Webkit https://github.com/zloirock/core-js/issues/898

// argumentsList[@@iterator] is %ArrayProto_values%

// browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339

// but their correct versions are not interesting for us

// can throw

// check on default Array iterator

// check that a method works with the correct list

// constructor polyfill

// contained in target

// cross-realm fallback

// define iterator

// deoptimization and performance degradation

// deoptimization and serious performance degradation

// eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing

// eslint-disable-next-line es/no-array-isarray -- safe

// eslint-disable-next-line es/no-array-prototype-includes -- detection

// eslint-disable-next-line es/no-function-prototype-bind -- detection

// eslint-disable-next-line es/no-function-prototype-bind -- safe

// eslint-disable-next-line es/no-function-prototype-bind, es/no-reflect -- safe

// eslint-disable-next-line es/no-global-this -- safe

// eslint-disable-next-line es/no-math-trunc -- safe

// eslint-disable-next-line es/no-object-create -- safe

// eslint-disable-next-line es/no-object-defineproperties -- safe

// eslint-disable-next-line es/no-object-defineproperty -- required for testing

// eslint-disable-next-line es/no-object-defineproperty -- safe

// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe

// eslint-disable-next-line es/no-object-getownpropertynames -- safe

// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing

// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe

// eslint-disable-next-line es/no-object-getprototypeof -- required for testing

// eslint-disable-next-line es/no-object-getprototypeof -- safe

// eslint-disable-next-line es/no-object-hasown -- safe

// eslint-disable-next-line es/no-object-keys -- safe

// eslint-disable-next-line es/no-object-setprototypeof -- safe

// eslint-disable-next-line no-console -- safe

// eslint-disable-next-line no-extend-native -- required

// eslint-disable-next-line no-new-func -- fallback

// eslint-disable-next-line no-prototype-builtins -- safe

// eslint-disable-next-line no-restricted-globals -- safe

// eslint-disable-next-line no-self-assign -- dirty hack

// eslint-disable-next-line no-self-compare -- NaN check

// eslint-disable-next-line no-unused-vars -- required for .length

// eslint-disable-next-line no-unused-vars -- required for `.length`

// eslint-disable-next-line no-useless-assignment -- avoid memory leak

// eslint-disable-next-line no-useless-call -- required for testing

// eslint-disable-next-line redos/no-vulnerable -- safe

// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing

// even if prevent traditional login is on.

// every

// export additional methods

// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window

// fallback for non-array-like ES3 and non-enumerable old V8 strings

// filter

// filterReject

// find

// findIndex

// fix Array.prototype.{ values, @@iterator }.name in V8 / FF

// fix for Safari 12.0 bug

// fix native

// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods

// getting tag from ES6+ `Object.prototype.toString`

// https://bugs.chromium.org/p/chromium/issues/detail?id=830565

// https://bugs.chromium.org/p/v8/issues/detail?id=3334

// https://bugs.webkit.org/show_bug.cgi?id=188794

// https://github.com/mathiasbynens/String.prototype.at

// https://github.com/oven-sh/bun/issues/1633

// https://github.com/tc39/proposal-array-filtering

// https://github.com/zloirock/core-js/issues/475

// https://github.com/zloirock/core-js/issues/640

// https://github.com/zloirock/core-js/issues/677

// https://github.com/zloirock/core-js/issues/679

// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028

// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval

// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout

// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers

// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next

// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator

// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next

// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot

// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec

// https://tc39.es/ecma262/#sec-array.prototype-@@iterator

// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables

// https://tc39.es/ecma262/#sec-array.prototype.entries

// https://tc39.es/ecma262/#sec-array.prototype.every

// https://tc39.es/ecma262/#sec-array.prototype.filter

// https://tc39.es/ecma262/#sec-array.prototype.find

// https://tc39.es/ecma262/#sec-array.prototype.findIndex

// https://tc39.es/ecma262/#sec-array.prototype.foreach

// https://tc39.es/ecma262/#sec-array.prototype.includes

// https://tc39.es/ecma262/#sec-array.prototype.indexof

// https://tc39.es/ecma262/#sec-array.prototype.keys

// https://tc39.es/ecma262/#sec-array.prototype.map

// https://tc39.es/ecma262/#sec-array.prototype.reverse

// https://tc39.es/ecma262/#sec-array.prototype.some

// https://tc39.es/ecma262/#sec-array.prototype.values

// https://tc39.es/ecma262/#sec-arrayspeciescreate

// https://tc39.es/ecma262/#sec-createarrayiterator

// https://tc39.es/ecma262/#sec-createiterresultobject

// https://tc39.es/ecma262/#sec-createmappedargumentsobject

// https://tc39.es/ecma262/#sec-createunmappedargumentsobject

// https://tc39.es/ecma262/#sec-function-instances-name

// https://tc39.es/ecma262/#sec-function.prototype.bind

// https://tc39.es/ecma262/#sec-getmethod

// https://tc39.es/ecma262/#sec-hasownproperty

// https://tc39.es/ecma262/#sec-isarray

// https://tc39.es/ecma262/#sec-iscallable

// https://tc39.es/ecma262/#sec-isconstructor

// https://tc39.es/ecma262/#sec-isregexp

// https://tc39.es/ecma262/#sec-json-@@tostringtag

// https://tc39.es/ecma262/#sec-json.stringify

// https://tc39.es/ecma262/#sec-lengthofarraylike

// https://tc39.es/ecma262/#sec-math-@@tostringtag

// https://tc39.es/ecma262/#sec-math.trunc

// https://tc39.es/ecma262/#sec-newpromisecapability

// https://tc39.es/ecma262/#sec-object.create

// https://tc39.es/ecma262/#sec-object.defineproperties

// https://tc39.es/ecma262/#sec-object.defineproperty

// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor

// https://tc39.es/ecma262/#sec-object.getownpropertydescriptors

// https://tc39.es/ecma262/#sec-object.getownpropertynames

// https://tc39.es/ecma262/#sec-object.getownpropertysymbols

// https://tc39.es/ecma262/#sec-object.getprototypeof

// https://tc39.es/ecma262/#sec-object.keys

// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable

// https://tc39.es/ecma262/#sec-object.prototype.tostring

// https://tc39.es/ecma262/#sec-object.setprototypeof

// https://tc39.es/ecma262/#sec-ordinarytoprimitive

// https://tc39.es/ecma262/#sec-promise-executor

// https://tc39.es/ecma262/#sec-promise.all

// https://tc39.es/ecma262/#sec-promise.prototype.catch

// https://tc39.es/ecma262/#sec-promise.prototype.then

// https://tc39.es/ecma262/#sec-promise.race

// https://tc39.es/ecma262/#sec-promise.reject

// https://tc39.es/ecma262/#sec-promise.resolve

// https://tc39.es/ecma262/#sec-requireobjectcoercible

// https://tc39.es/ecma262/#sec-speciesconstructor

// https://tc39.es/ecma262/#sec-string.prototype-@@iterator

// https://tc39.es/ecma262/#sec-string.prototype.codepointat

// https://tc39.es/ecma262/#sec-string.prototype.endswith

// https://tc39.es/ecma262/#sec-string.prototype.includes

// https://tc39.es/ecma262/#sec-string.prototype.startswith

// https://tc39.es/ecma262/#sec-string.prototype.trim

// https://tc39.es/ecma262/#sec-string.prototype.trimend

// https://tc39.es/ecma262/#sec-string.prototype.trimstart

// https://tc39.es/ecma262/#sec-symbol-constructor

// https://tc39.es/ecma262/#sec-symbol.asynciterator

// https://tc39.es/ecma262/#sec-symbol.for

// https://tc39.es/ecma262/#sec-symbol.iterator

// https://tc39.es/ecma262/#sec-symbol.keyfor

// https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive

// https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag

// https://tc39.es/ecma262/#sec-symbol.prototype.description

// https://tc39.es/ecma262/#sec-symbol.tostringtag

// https://tc39.es/ecma262/#sec-tointegerorinfinity

// https://tc39.es/ecma262/#sec-tolength

// https://tc39.es/ecma262/#sec-toobject

// https://tc39.es/ecma262/#sec-toprimitive

// https://tc39.es/ecma262/#sec-topropertykey

// in old Chrome, versions of V8 isn't V8 = Chrome / 10

// in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList`

// iterable DOM collections

// loginState.isTraditionalLoginPreventedForUser might be null

// make `.constructor === Promise` work for native promise-based APIs

// make `Promise#then` return a polyfilled `Promise` for native promise-based APIs

// make `instanceof Promise` work for native promise-based APIs

// makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`

// map

// modern engines have queueMicrotask method

// nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,

// next index

// of course, fail.

// of whitespaces and has a correct name

// old engines have not location.origin

// optimisation for array iterators

// optional / simple context binding

// so check `userAgent` even if `.v8` exists, but 0

// some

// some Chrome versions have non-configurable methods on DOMTokenList

// some old implementations (like WebKit) could pass numbers as keys

// target

// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper

// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346

// toObject with fallback for non-array-like ES3 strings

// we can't check .prototype since constructors produced by .bind haven't it

// we can't use just `it == null` since of `document.all` special case

// webpackRuntimeModules

// with adding support of @@species

// workaround of WebKit ~ iOS Safari 10.1 bug

// workaround of old WebKit + `eval` bug

// wrap Symbol constructor for correct work with undefined description

//@ts-ignore

//@ts-ignore: We handle the check below

//useKssoLoginPage();
