oef/dist/main.bundle.js
2019-11-04 15:00:46 +01:00

26168 lines
No EOL
2.2 MiB

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* jQuery JavaScript Library v3.4.1
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2019-05-01T21:04Z
*/
( function( global, factory ) {
"use strict";
if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
// For environments that do not have a `window` with a `document`
// (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info.
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
// enough that all such attempts are guarded in a try block.
"use strict";
var arr = [];
var document = window.document;
var getProto = Object.getPrototypeOf;
var slice = arr.slice;
var concat = arr.concat;
var push = arr.push;
var indexOf = arr.indexOf;
var class2type = {};
var toString = class2type.toString;
var hasOwn = class2type.hasOwnProperty;
var fnToString = hasOwn.toString;
var ObjectFunctionString = fnToString.call( Object );
var support = {};
var isFunction = function isFunction( obj ) {
// Support: Chrome <=57, Firefox <=52
// In some browsers, typeof returns "function" for HTML <object> elements
// (i.e., `typeof document.createElement( "object" ) === "function"`).
// We don't want to classify *any* DOM node as a function.
return typeof obj === "function" && typeof obj.nodeType !== "number";
};
var isWindow = function isWindow( obj ) {
return obj != null && obj === obj.window;
};
var preservedScriptAttributes = {
type: true,
src: true,
nonce: true,
noModule: true
};
function DOMEval( code, node, doc ) {
doc = doc || document;
var i, val,
script = doc.createElement( "script" );
script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
// Support: Firefox 64+, Edge 18+
// Some browsers don't support the "nonce" property on scripts.
// On the other hand, just using `getAttribute` is not enough as
// the `nonce` attribute is reset to an empty string whenever it
// becomes browsing-context connected.
// See https://github.com/whatwg/html/issues/2369
// See https://html.spec.whatwg.org/#nonce-attributes
// The `node.getAttribute` check was added for the sake of
// `jQuery.globalEval` so that it can fake a nonce-containing node
// via an object.
val = node[ i ] || node.getAttribute && node.getAttribute( i );
if ( val ) {
script.setAttribute( i, val );
}
}
}
doc.head.appendChild( script ).parentNode.removeChild( script );
}
function toType( obj ) {
if ( obj == null ) {
return obj + "";
}
// Support: Android <=2.3 only (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call( obj ) ] || "object" :
typeof obj;
}
/* global Symbol */
// Defining this global in .eslintrc.json would create a danger of using the global
// unguarded in another place, it seems safer to define global only for this module
var
version = "3.4.1",
// Define a local copy of jQuery
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included)
return new jQuery.fn.init( selector, context );
},
// Support: Android <=4.0 only
// Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
jquery: version,
constructor: jQuery,
// The default length of a jQuery object is 0
length: 0,
toArray: function() {
return slice.call( this );
},
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
// Return all the elements in a clean array
if ( num == null ) {
return slice.call( this );
}
// Return just the one element from the set
return num < 0 ? this[ num + this.length ] : this[ num ];
},
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function( elems ) {
// Build a new jQuery matched element set
var ret = jQuery.merge( this.constructor(), elems );
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
// Return the newly-formed element set
return ret;
},
// Execute a callback for every element in the matched set.
each: function( callback ) {
return jQuery.each( this, callback );
},
map: function( callback ) {
return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem );
} ) );
},
slice: function() {
return this.pushStack( slice.apply( this, arguments ) );
},
first: function() {
return this.eq( 0 );
},
last: function() {
return this.eq( -1 );
},
eq: function( i ) {
var len = this.length,
j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
},
end: function() {
return this.prevObject || this.constructor();
},
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: push,
sort: arr.sort,
splice: arr.splice
};
jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[ 0 ] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
// Skip the boolean and the target
target = arguments[ i ] || {};
i++;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !isFunction( target ) ) {
target = {};
}
// Extend jQuery itself if only one argument is passed
if ( i === length ) {
target = this;
i--;
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( ( options = arguments[ i ] ) != null ) {
// Extend the base object
for ( name in options ) {
copy = options[ name ];
// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( name === "__proto__" || target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
( copyIsArray = Array.isArray( copy ) ) ) ) {
src = target[ name ];
// Ensure proper type for the source value
if ( copyIsArray && !Array.isArray( src ) ) {
clone = [];
} else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
clone = {};
} else {
clone = src;
}
copyIsArray = false;
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};
jQuery.extend( {
// Unique for each copy of jQuery on the page
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
// Assume jQuery is ready without the ready module
isReady: true,
error: function( msg ) {
throw new Error( msg );
},
noop: function() {},
isPlainObject: function( obj ) {
var proto, Ctor;
// Detect obvious negatives
// Use toString instead of jQuery.type to catch host objects
if ( !obj || toString.call( obj ) !== "[object Object]" ) {
return false;
}
proto = getProto( obj );
// Objects with no prototype (e.g., `Object.create( null )`) are plain
if ( !proto ) {
return true;
}
// Objects with prototype are plain iff they were constructed by a global Object function
Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
},
isEmptyObject: function( obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
},
// Evaluates a script in a global context
globalEval: function( code, options ) {
DOMEval( code, { nonce: options && options.nonce } );
},
each: function( obj, callback ) {
var length, i = 0;
if ( isArrayLike( obj ) ) {
length = obj.length;
for ( ; i < length; i++ ) {
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break;
}
}
} else {
for ( i in obj ) {
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break;
}
}
}
return obj;
},
// Support: Android <=4.0 only
trim: function( text ) {
return text == null ?
"" :
( text + "" ).replace( rtrim, "" );
},
// results is for internal usage only
makeArray: function( arr, results ) {
var ret = results || [];
if ( arr != null ) {
if ( isArrayLike( Object( arr ) ) ) {
jQuery.merge( ret,
typeof arr === "string" ?
[ arr ] : arr
);
} else {
push.call( ret, arr );
}
}
return ret;
},
inArray: function( elem, arr, i ) {
return arr == null ? -1 : indexOf.call( arr, elem, i );
},
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
merge: function( first, second ) {
var len = +second.length,
j = 0,
i = first.length;
for ( ; j < len; j++ ) {
first[ i++ ] = second[ j ];
}
first.length = i;
return first;
},
grep: function( elems, callback, invert ) {
var callbackInverse,
matches = [],
i = 0,
length = elems.length,
callbackExpect = !invert;
// Go through the array, only saving the items
// that pass the validator function
for ( ; i < length; i++ ) {
callbackInverse = !callback( elems[ i ], i );
if ( callbackInverse !== callbackExpect ) {
matches.push( elems[ i ] );
}
}
return matches;
},
// arg is for internal usage only
map: function( elems, callback, arg ) {
var length, value,
i = 0,
ret = [];
// Go through the array, translating each of the items to their new values
if ( isArrayLike( elems ) ) {
length = elems.length;
for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret.push( value );
}
}
// Go through every key on the object,
} else {
for ( i in elems ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret.push( value );
}
}
}
// Flatten any nested arrays
return concat.apply( [], ret );
},
// A global GUID counter for objects
guid: 1,
// jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist.
support: support
} );
if ( typeof Symbol === "function" ) {
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
}
// Populate the class2type map
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
function( i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
} );
function isArrayLike( obj ) {
// Support: real iOS 8.2 only (not reproducible in simulator)
// `in` check used to prevent JIT error (gh-2145)
// hasOwn isn't used here due to false negatives
// regarding Nodelist length in IE
var length = !!obj && "length" in obj && obj.length,
type = toType( obj );
if ( isFunction( obj ) || isWindow( obj ) ) {
return false;
}
return type === "array" || length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
}
var Sizzle =
/*!
* Sizzle CSS Selector Engine v2.3.4
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2019-04-08
*/
(function( window ) {
var i,
support,
Expr,
getText,
isXML,
tokenize,
compile,
select,
outermostContext,
sortInput,
hasDuplicate,
// Local document vars
setDocument,
document,
docElem,
documentIsHTML,
rbuggyQSA,
rbuggyMatches,
matches,
contains,
// Instance-specific data
expando = "sizzle" + 1 * new Date(),
preferredDoc = window.document,
dirruns = 0,
done = 0,
classCache = createCache(),
tokenCache = createCache(),
compilerCache = createCache(),
nonnativeSelectorCache = createCache(),
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
}
return 0;
},
// Instance methods
hasOwn = ({}).hasOwnProperty,
arr = [],
pop = arr.pop,
push_native = arr.push,
push = arr.push,
slice = arr.slice,
// Use a stripped-down indexOf as it's faster than native
// https://jsperf.com/thor-indexof-vs-for/5
indexOf = function( list, elem ) {
var i = 0,
len = list.length;
for ( ; i < len; i++ ) {
if ( list[i] === elem ) {
return i;
}
}
return -1;
},
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
// Regular expressions
// http://www.w3.org/TR/css3-selectors/#whitespace
whitespace = "[\\x20\\t\\r\\n\\f]",
// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
// Operator (capture 2)
"*([*^$|!~]?=)" + whitespace +
// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
"*\\]",
pseudos = ":(" + identifier + ")(?:\\((" +
// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
// 1. quoted (capture 3; capture 4 or capture 5)
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
// 2. simple (capture 6)
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
// 3. anything else (capture 2)
".*" +
")\\)|)",
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
rwhitespace = new RegExp( whitespace + "+", "g" ),
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
rdescend = new RegExp( whitespace + "|>" ),
rpseudo = new RegExp( pseudos ),
ridentifier = new RegExp( "^" + identifier + "$" ),
matchExpr = {
"ID": new RegExp( "^#(" + identifier + ")" ),
"CLASS": new RegExp( "^\\.(" + identifier + ")" ),
"TAG": new RegExp( "^(" + identifier + "|[*])" ),
"ATTR": new RegExp( "^" + attributes ),
"PSEUDO": new RegExp( "^" + pseudos ),
"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
"bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
// For use in libraries implementing .is()
// We use this for POS matching in `select`
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
},
rhtml = /HTML$/i,
rinputs = /^(?:input|select|textarea|button)$/i,
rheader = /^h\d$/i,
rnative = /^[^{]+\{\s*\[native \w/,
// Easily-parseable/retrievable ID or TAG or CLASS selectors
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
rsibling = /[+~]/,
// CSS escapes
// http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
funescape = function( _, escaped, escapedWhitespace ) {
var high = "0x" + escaped - 0x10000;
// NaN means non-codepoint
// Support: Firefox<24
// Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ?
escaped :
high < 0 ?
// BMP codepoint
String.fromCharCode( high + 0x10000 ) :
// Supplemental Plane codepoint (surrogate pair)
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
},
// CSS string/identifier serialization
// https://drafts.csswg.org/cssom/#common-serializing-idioms
rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
fcssescape = function( ch, asCodePoint ) {
if ( asCodePoint ) {
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
if ( ch === "\0" ) {
return "\uFFFD";
}
// Control characters and (dependent upon position) numbers get escaped as code points
return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
}
// Other potentially-special ASCII characters get backslash-escaped
return "\\" + ch;
},
// Used for iframes
// See setDocument()
// Removing the function wrapper causes a "Permission Denied"
// error in IE
unloadHandler = function() {
setDocument();
},
inDisabledFieldset = addCombinator(
function( elem ) {
return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
},
{ dir: "parentNode", next: "legend" }
);
// Optimize for push.apply( _, NodeList )
try {
push.apply(
(arr = slice.call( preferredDoc.childNodes )),
preferredDoc.childNodes
);
// Support: Android<4.0
// Detect silently failing push.apply
arr[ preferredDoc.childNodes.length ].nodeType;
} catch ( e ) {
push = { apply: arr.length ?
// Leverage slice if possible
function( target, els ) {
push_native.apply( target, slice.call(els) );
} :
// Support: IE<9
// Otherwise append directly
function( target, els ) {
var j = target.length,
i = 0;
// Can't trust NodeList.length
while ( (target[j++] = els[i++]) ) {}
target.length = j - 1;
}
};
}
function Sizzle( selector, context, results, seed ) {
var m, i, elem, nid, match, groups, newSelector,
newContext = context && context.ownerDocument,
// nodeType defaults to 9, since context defaults to document
nodeType = context ? context.nodeType : 9;
results = results || [];
// Return early from calls with invalid selector or context
if ( typeof selector !== "string" || !selector ||
nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
return results;
}
// Try to shortcut find operations (as opposed to filters) in HTML documents
if ( !seed ) {
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
setDocument( context );
}
context = context || document;
if ( documentIsHTML ) {
// If the selector is sufficiently simple, try using a "get*By*" DOM method
// (excepting DocumentFragment context, where the methods don't exist)
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
// ID selector
if ( (m = match[1]) ) {
// Document context
if ( nodeType === 9 ) {
if ( (elem = context.getElementById( m )) ) {
// Support: IE, Opera, Webkit
// TODO: identify versions
// getElementById can match elements by name instead of ID
if ( elem.id === m ) {
results.push( elem );
return results;
}
} else {
return results;
}
// Element context
} else {
// Support: IE, Opera, Webkit
// TODO: identify versions
// getElementById can match elements by name instead of ID
if ( newContext && (elem = newContext.getElementById( m )) &&
contains( context, elem ) &&
elem.id === m ) {
results.push( elem );
return results;
}
}
// Type selector
} else if ( match[2] ) {
push.apply( results, context.getElementsByTagName( selector ) );
return results;
// Class selector
} else if ( (m = match[3]) && support.getElementsByClassName &&
context.getElementsByClassName ) {
push.apply( results, context.getElementsByClassName( m ) );
return results;
}
}
// Take advantage of querySelectorAll
if ( support.qsa &&
!nonnativeSelectorCache[ selector + " " ] &&
(!rbuggyQSA || !rbuggyQSA.test( selector )) &&
// Support: IE 8 only
// Exclude object elements
(nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
newSelector = selector;
newContext = context;
// qSA considers elements outside a scoping root when evaluating child or
// descendant combinators, which is not what we want.
// In such cases, we work around the behavior by prefixing every selector in the
// list with an ID selector referencing the scope context.
// Thanks to Andrew Dupont for this technique.
if ( nodeType === 1 && rdescend.test( selector ) ) {
// Capture the context ID, setting it first if necessary
if ( (nid = context.getAttribute( "id" )) ) {
nid = nid.replace( rcssescape, fcssescape );
} else {
context.setAttribute( "id", (nid = expando) );
}
// Prefix every selector in the list
groups = tokenize( selector );
i = groups.length;
while ( i-- ) {
groups[i] = "#" + nid + " " + toSelector( groups[i] );
}
newSelector = groups.join( "," );
// Expand context for sibling selectors
newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
context;
}
try {
push.apply( results,
newContext.querySelectorAll( newSelector )
);
return results;
} catch ( qsaError ) {
nonnativeSelectorCache( selector, true );
} finally {
if ( nid === expando ) {
context.removeAttribute( "id" );
}
}
}
}
}
// All others
return select( selector.replace( rtrim, "$1" ), context, results, seed );
}
/**
* Create key-value caches of limited size
* @returns {function(string, object)} Returns the Object data after storing it on itself with
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
* deleting the oldest entry
*/
function createCache() {
var keys = [];
function cache( key, value ) {
// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
if ( keys.push( key + " " ) > Expr.cacheLength ) {
// Only keep the most recent entries
delete cache[ keys.shift() ];
}
return (cache[ key + " " ] = value);
}
return cache;
}
/**
* Mark a function for special use by Sizzle
* @param {Function} fn The function to mark
*/
function markFunction( fn ) {
fn[ expando ] = true;
return fn;
}
/**
* Support testing using an element
* @param {Function} fn Passed the created element and returns a boolean result
*/
function assert( fn ) {
var el = document.createElement("fieldset");
try {
return !!fn( el );
} catch (e) {
return false;
} finally {
// Remove from its parent by default
if ( el.parentNode ) {
el.parentNode.removeChild( el );
}
// release memory in IE
el = null;
}
}
/**
* Adds the same handler for all of the specified attrs
* @param {String} attrs Pipe-separated list of attributes
* @param {Function} handler The method that will be applied
*/
function addHandle( attrs, handler ) {
var arr = attrs.split("|"),
i = arr.length;
while ( i-- ) {
Expr.attrHandle[ arr[i] ] = handler;
}
}
/**
* Checks document order of two siblings
* @param {Element} a
* @param {Element} b
* @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
*/
function siblingCheck( a, b ) {
var cur = b && a,
diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
a.sourceIndex - b.sourceIndex;
// Use IE sourceIndex if available on both nodes
if ( diff ) {
return diff;
}
// Check if b follows a
if ( cur ) {
while ( (cur = cur.nextSibling) ) {
if ( cur === b ) {
return -1;
}
}
}
return a ? 1 : -1;
}
/**
* Returns a function to use in pseudos for input types
* @param {String} type
*/
function createInputPseudo( type ) {
return function( elem ) {
var name = elem.nodeName.toLowerCase();
return name === "input" && elem.type === type;
};
}
/**
* Returns a function to use in pseudos for buttons
* @param {String} type
*/
function createButtonPseudo( type ) {
return function( elem ) {
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && elem.type === type;
};
}
/**
* Returns a function to use in pseudos for :enabled/:disabled
* @param {Boolean} disabled true for :disabled; false for :enabled
*/
function createDisabledPseudo( disabled ) {
// Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
return function( elem ) {
// Only certain elements can match :enabled or :disabled
// https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
// https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
if ( "form" in elem ) {
// Check for inherited disabledness on relevant non-disabled elements:
// * listed form-associated elements in a disabled fieldset
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
// * option elements in a disabled optgroup
// https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
// All such elements have a "form" property.
if ( elem.parentNode && elem.disabled === false ) {
// Option elements defer to a parent optgroup if present
if ( "label" in elem ) {
if ( "label" in elem.parentNode ) {
return elem.parentNode.disabled === disabled;
} else {
return elem.disabled === disabled;
}
}
// Support: IE 6 - 11
// Use the isDisabled shortcut property to check for disabled fieldset ancestors
return elem.isDisabled === disabled ||
// Where there is no isDisabled, check manually
/* jshint -W018 */
elem.isDisabled !== !disabled &&
inDisabledFieldset( elem ) === disabled;
}
return elem.disabled === disabled;
// Try to winnow out elements that can't be disabled before trusting the disabled property.
// Some victims get caught in our net (label, legend, menu, track), but it shouldn't
// even exist on them, let alone have a boolean value.
} else if ( "label" in elem ) {
return elem.disabled === disabled;
}
// Remaining elements are neither :enabled nor :disabled
return false;
};
}
/**
* Returns a function to use in pseudos for positionals
* @param {Function} fn
*/
function createPositionalPseudo( fn ) {
return markFunction(function( argument ) {
argument = +argument;
return markFunction(function( seed, matches ) {
var j,
matchIndexes = fn( [], seed.length, argument ),
i = matchIndexes.length;
// Match elements found at the specified indexes
while ( i-- ) {
if ( seed[ (j = matchIndexes[i]) ] ) {
seed[j] = !(matches[j] = seed[j]);
}
}
});
});
}
/**
* Checks a node for validity as a Sizzle context
* @param {Element|Object=} context
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
*/
function testContext( context ) {
return context && typeof context.getElementsByTagName !== "undefined" && context;
}
// Expose support vars for convenience
support = Sizzle.support = {};
/**
* Detects XML nodes
* @param {Element|Object} elem An element or a document
* @returns {Boolean} True iff elem is a non-HTML XML node
*/
isXML = Sizzle.isXML = function( elem ) {
var namespace = elem.namespaceURI,
docElem = (elem.ownerDocument || elem).documentElement;
// Support: IE <=8
// Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
// https://bugs.jquery.com/ticket/4833
return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
};
/**
* Sets document-related variables once based on the current document
* @param {Element|Object} [doc] An element or document object to use to set the document
* @returns {Object} Returns the current document
*/
setDocument = Sizzle.setDocument = function( node ) {
var hasCompare, subWindow,
doc = node ? node.ownerDocument || node : preferredDoc;
// Return early if doc is invalid or already selected
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
return document;
}
// Update global variables
document = doc;
docElem = document.documentElement;
documentIsHTML = !isXML( document );
// Support: IE 9-11, Edge
// Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
if ( preferredDoc !== document &&
(subWindow = document.defaultView) && subWindow.top !== subWindow ) {
// Support: IE 11, Edge
if ( subWindow.addEventListener ) {
subWindow.addEventListener( "unload", unloadHandler, false );
// Support: IE 9 - 10 only
} else if ( subWindow.attachEvent ) {
subWindow.attachEvent( "onunload", unloadHandler );
}
}
/* Attributes
---------------------------------------------------------------------- */
// Support: IE<8
// Verify that getAttribute really returns attributes and not properties
// (excepting IE8 booleans)
support.attributes = assert(function( el ) {
el.className = "i";
return !el.getAttribute("className");
});
/* getElement(s)By*
---------------------------------------------------------------------- */
// Check if getElementsByTagName("*") returns only elements
support.getElementsByTagName = assert(function( el ) {
el.appendChild( document.createComment("") );
return !el.getElementsByTagName("*").length;
});
// Support: IE<9
support.getElementsByClassName = rnative.test( document.getElementsByClassName );
// Support: IE<10
// Check if getElementById returns elements by name
// The broken getElementById methods don't pick up programmatically-set names,
// so use a roundabout getElementsByName test
support.getById = assert(function( el ) {
docElem.appendChild( el ).id = expando;
return !document.getElementsByName || !document.getElementsByName( expando ).length;
});
// ID filter and find
if ( support.getById ) {
Expr.filter["ID"] = function( id ) {
var attrId = id.replace( runescape, funescape );
return function( elem ) {
return elem.getAttribute("id") === attrId;
};
};
Expr.find["ID"] = function( id, context ) {
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
var elem = context.getElementById( id );
return elem ? [ elem ] : [];
}
};
} else {
Expr.filter["ID"] = function( id ) {
var attrId = id.replace( runescape, funescape );
return function( elem ) {
var node = typeof elem.getAttributeNode !== "undefined" &&
elem.getAttributeNode("id");
return node && node.value === attrId;
};
};
// Support: IE 6 - 7 only
// getElementById is not reliable as a find shortcut
Expr.find["ID"] = function( id, context ) {
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
var node, i, elems,
elem = context.getElementById( id );
if ( elem ) {
// Verify the id attribute
node = elem.getAttributeNode("id");
if ( node && node.value === id ) {
return [ elem ];
}
// Fall back on getElementsByName
elems = context.getElementsByName( id );
i = 0;
while ( (elem = elems[i++]) ) {
node = elem.getAttributeNode("id");
if ( node && node.value === id ) {
return [ elem ];
}
}
}
return [];
}
};
}
// Tag
Expr.find["TAG"] = support.getElementsByTagName ?
function( tag, context ) {
if ( typeof context.getElementsByTagName !== "undefined" ) {
return context.getElementsByTagName( tag );
// DocumentFragment nodes don't have gEBTN
} else if ( support.qsa ) {
return context.querySelectorAll( tag );
}
} :
function( tag, context ) {
var elem,
tmp = [],
i = 0,
// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
results = context.getElementsByTagName( tag );
// Filter out possible comments
if ( tag === "*" ) {
while ( (elem = results[i++]) ) {
if ( elem.nodeType === 1 ) {
tmp.push( elem );
}
}
return tmp;
}
return results;
};
// Class
Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
return context.getElementsByClassName( className );
}
};
/* QSA/matchesSelector
---------------------------------------------------------------------- */
// QSA and matchesSelector support
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
rbuggyMatches = [];
// qSa(:focus) reports false when true (Chrome 21)
// We allow this because of a bug in IE8/9 that throws an error
// whenever `document.activeElement` is accessed on an iframe
// So, we allow :focus to pass through QSA all the time to avoid the IE error
// See https://bugs.jquery.com/ticket/13378
rbuggyQSA = [];
if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
// Build QSA regex
// Regex strategy adopted from Diego Perini
assert(function( el ) {
// Select is set to empty string on purpose
// This is to test IE's treatment of not explicitly
// setting a boolean content attribute,
// since its presence should be enough
// https://bugs.jquery.com/ticket/12359
docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
"<select id='" + expando + "-\r\\' msallowcapture=''>" +
"<option selected=''></option></select>";
// Support: IE8, Opera 11-12.16
// Nothing should be selected when empty strings follow ^= or $= or *=
// The test attribute must be unknown in Opera but "safe" for WinRT
// https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
if ( el.querySelectorAll("[msallowcapture^='']").length ) {
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
}
// Support: IE8
// Boolean attributes and "value" are not treated correctly
if ( !el.querySelectorAll("[selected]").length ) {
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
}
// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
rbuggyQSA.push("~=");
}
// Webkit/Opera - :checked should return selected option elements
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
// IE8 throws error here and will not see later tests
if ( !el.querySelectorAll(":checked").length ) {
rbuggyQSA.push(":checked");
}
// Support: Safari 8+, iOS 8+
// https://bugs.webkit.org/show_bug.cgi?id=136851
// In-page `selector#id sibling-combinator selector` fails
if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
rbuggyQSA.push(".#.+[+~]");
}
});
assert(function( el ) {
el.innerHTML = "<a href='' disabled='disabled'></a>" +
"<select disabled='disabled'><option/></select>";
// Support: Windows 8 Native Apps
// The type and name attributes are restricted during .innerHTML assignment
var input = document.createElement("input");
input.setAttribute( "type", "hidden" );
el.appendChild( input ).setAttribute( "name", "D" );
// Support: IE8
// Enforce case-sensitivity of name attribute
if ( el.querySelectorAll("[name=d]").length ) {
rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
}
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
// IE8 throws error here and will not see later tests
if ( el.querySelectorAll(":enabled").length !== 2 ) {
rbuggyQSA.push( ":enabled", ":disabled" );
}
// Support: IE9-11+
// IE's :disabled selector does not pick up the children of disabled fieldsets
docElem.appendChild( el ).disabled = true;
if ( el.querySelectorAll(":disabled").length !== 2 ) {
rbuggyQSA.push( ":enabled", ":disabled" );
}
// Opera 10-11 does not throw on post-comma invalid pseudos
el.querySelectorAll("*,:x");
rbuggyQSA.push(",.*:");
});
}
if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
docElem.webkitMatchesSelector ||
docElem.mozMatchesSelector ||
docElem.oMatchesSelector ||
docElem.msMatchesSelector) )) ) {
assert(function( el ) {
// Check to see if it's possible to do matchesSelector
// on a disconnected node (IE 9)
support.disconnectedMatch = matches.call( el, "*" );
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call( el, "[s!='']:x" );
rbuggyMatches.push( "!=", pseudos );
});
}
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
/* Contains
---------------------------------------------------------------------- */
hasCompare = rnative.test( docElem.compareDocumentPosition );
// Element contains another
// Purposefully self-exclusive
// As in, an element does not contain itself
contains = hasCompare || rnative.test( docElem.contains ) ?
function( a, b ) {
var adown = a.nodeType === 9 ? a.documentElement : a,
bup = b && b.parentNode;
return a === bup || !!( bup && bup.nodeType === 1 && (
adown.contains ?
adown.contains( bup ) :
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
));
} :
function( a, b ) {
if ( b ) {
while ( (b = b.parentNode) ) {
if ( b === a ) {
return true;
}
}
}
return false;
};
/* Sorting
---------------------------------------------------------------------- */
// Document order sorting
sortOrder = hasCompare ?
function( a, b ) {
// Flag for duplicate removal
if ( a === b ) {
hasDuplicate = true;
return 0;
}
// Sort on method existence if only one input has compareDocumentPosition
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
if ( compare ) {
return compare;
}
// Calculate position if both inputs belong to the same document
compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
a.compareDocumentPosition( b ) :
// Otherwise we know they are disconnected
1;
// Disconnected nodes
if ( compare & 1 ||
(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
// Choose the first element that is related to our preferred document
if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
return -1;
}
if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
return 1;
}
// Maintain original order
return sortInput ?
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
0;
}
return compare & 4 ? -1 : 1;
} :
function( a, b ) {
// Exit early if the nodes are identical
if ( a === b ) {
hasDuplicate = true;
return 0;
}
var cur,
i = 0,
aup = a.parentNode,
bup = b.parentNode,
ap = [ a ],
bp = [ b ];
// Parentless nodes are either documents or disconnected
if ( !aup || !bup ) {
return a === document ? -1 :
b === document ? 1 :
aup ? -1 :
bup ? 1 :
sortInput ?
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
0;
// If the nodes are siblings, we can do a quick check
} else if ( aup === bup ) {
return siblingCheck( a, b );
}
// Otherwise we need full lists of their ancestors for comparison
cur = a;
while ( (cur = cur.parentNode) ) {
ap.unshift( cur );
}
cur = b;
while ( (cur = cur.parentNode) ) {
bp.unshift( cur );
}
// Walk down the tree looking for a discrepancy
while ( ap[i] === bp[i] ) {
i++;
}
return i ?
// Do a sibling check if the nodes have a common ancestor
siblingCheck( ap[i], bp[i] ) :
// Otherwise nodes in our document sort first
ap[i] === preferredDoc ? -1 :
bp[i] === preferredDoc ? 1 :
0;
};
return document;
};
Sizzle.matches = function( expr, elements ) {
return Sizzle( expr, null, null, elements );
};
Sizzle.matchesSelector = function( elem, expr ) {
// Set document vars if needed
if ( ( elem.ownerDocument || elem ) !== document ) {
setDocument( elem );
}
if ( support.matchesSelector && documentIsHTML &&
!nonnativeSelectorCache[ expr + " " ] &&
( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
try {
var ret = matches.call( elem, expr );
// IE 9's matchesSelector returns false on disconnected nodes
if ( ret || support.disconnectedMatch ||
// As well, disconnected nodes are said to be in a document
// fragment in IE 9
elem.document && elem.document.nodeType !== 11 ) {
return ret;
}
} catch (e) {
nonnativeSelectorCache( expr, true );
}
}
return Sizzle( expr, document, null, [ elem ] ).length > 0;
};
Sizzle.contains = function( context, elem ) {
// Set document vars if needed
if ( ( context.ownerDocument || context ) !== document ) {
setDocument( context );
}
return contains( context, elem );
};
Sizzle.attr = function( elem, name ) {
// Set document vars if needed
if ( ( elem.ownerDocument || elem ) !== document ) {
setDocument( elem );
}
var fn = Expr.attrHandle[ name.toLowerCase() ],
// Don't get fooled by Object.prototype properties (jQuery #13807)
val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
fn( elem, name, !documentIsHTML ) :
undefined;
return val !== undefined ?
val :
support.attributes || !documentIsHTML ?
elem.getAttribute( name ) :
(val = elem.getAttributeNode(name)) && val.specified ?
val.value :
null;
};
Sizzle.escape = function( sel ) {
return (sel + "").replace( rcssescape, fcssescape );
};
Sizzle.error = function( msg ) {
throw new Error( "Syntax error, unrecognized expression: " + msg );
};
/**
* Document sorting and removing duplicates
* @param {ArrayLike} results
*/
Sizzle.uniqueSort = function( results ) {
var elem,
duplicates = [],
j = 0,
i = 0;
// Unless we *know* we can detect duplicates, assume their presence
hasDuplicate = !support.detectDuplicates;
sortInput = !support.sortStable && results.slice( 0 );
results.sort( sortOrder );
if ( hasDuplicate ) {
while ( (elem = results[i++]) ) {
if ( elem === results[ i ] ) {
j = duplicates.push( i );
}
}
while ( j-- ) {
results.splice( duplicates[ j ], 1 );
}
}
// Clear input after sorting to release objects
// See https://github.com/jquery/sizzle/pull/225
sortInput = null;
return results;
};
/**
* Utility function for retrieving the text value of an array of DOM nodes
* @param {Array|Element} elem
*/
getText = Sizzle.getText = function( elem ) {
var node,
ret = "",
i = 0,
nodeType = elem.nodeType;
if ( !nodeType ) {
// If no nodeType, this is expected to be an array
while ( (node = elem[i++]) ) {
// Do not traverse comment nodes
ret += getText( node );
}
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
// Use textContent for elements
// innerText usage removed for consistency of new lines (jQuery #11153)
if ( typeof elem.textContent === "string" ) {
return elem.textContent;
} else {
// Traverse its children
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
ret += getText( elem );
}
}
} else if ( nodeType === 3 || nodeType === 4 ) {
return elem.nodeValue;
}
// Do not include comment or processing instruction nodes
return ret;
};
Expr = Sizzle.selectors = {
// Can be adjusted by the user
cacheLength: 50,
createPseudo: markFunction,
match: matchExpr,
attrHandle: {},
find: {},
relative: {
">": { dir: "parentNode", first: true },
" ": { dir: "parentNode" },
"+": { dir: "previousSibling", first: true },
"~": { dir: "previousSibling" }
},
preFilter: {
"ATTR": function( match ) {
match[1] = match[1].replace( runescape, funescape );
// Move the given value to match[3] whether quoted or unquoted
match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
if ( match[2] === "~=" ) {
match[3] = " " + match[3] + " ";
}
return match.slice( 0, 4 );
},
"CHILD": function( match ) {
/* matches from matchExpr["CHILD"]
1 type (only|nth|...)
2 what (child|of-type)
3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4 xn-component of xn+y argument ([+-]?\d*n|)
5 sign of xn-component
6 x of xn-component
7 sign of y-component
8 y of y-component
*/
match[1] = match[1].toLowerCase();
if ( match[1].slice( 0, 3 ) === "nth" ) {
// nth-* requires argument
if ( !match[3] ) {
Sizzle.error( match[0] );
}
// numeric x and y parameters for Expr.filter.CHILD
// remember that false/true cast respectively to 0/1
match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
// other types prohibit arguments
} else if ( match[3] ) {
Sizzle.error( match[0] );
}
return match;
},
"PSEUDO": function( match ) {
var excess,
unquoted = !match[6] && match[2];
if ( matchExpr["CHILD"].test( match[0] ) ) {
return null;
}
// Accept quoted arguments as-is
if ( match[3] ) {
match[2] = match[4] || match[5] || "";
// Strip excess characters from unquoted arguments
} else if ( unquoted && rpseudo.test( unquoted ) &&
// Get excess from tokenize (recursively)
(excess = tokenize( unquoted, true )) &&
// advance to the next closing parenthesis
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
// excess is a negative index
match[0] = match[0].slice( 0, excess );
match[2] = unquoted.slice( 0, excess );
}
// Return only captures needed by the pseudo filter method (type and argument)
return match.slice( 0, 3 );
}
},
filter: {
"TAG": function( nodeNameSelector ) {
var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
return nodeNameSelector === "*" ?
function() { return true; } :
function( elem ) {
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
};
},
"CLASS": function( className ) {
var pattern = classCache[ className + " " ];
return pattern ||
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
classCache( className, function( elem ) {
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
});
},
"ATTR": function( name, operator, check ) {
return function( elem ) {
var result = Sizzle.attr( elem, name );
if ( result == null ) {
return operator === "!=";
}
if ( !operator ) {
return true;
}
result += "";
return operator === "=" ? result === check :
operator === "!=" ? result !== check :
operator === "^=" ? check && result.indexOf( check ) === 0 :
operator === "*=" ? check && result.indexOf( check ) > -1 :
operator === "$=" ? check && result.slice( -check.length ) === check :
operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
false;
};
},
"CHILD": function( type, what, argument, first, last ) {
var simple = type.slice( 0, 3 ) !== "nth",
forward = type.slice( -4 ) !== "last",
ofType = what === "of-type";
return first === 1 && last === 0 ?
// Shortcut for :nth-*(n)
function( elem ) {
return !!elem.parentNode;
} :
function( elem, context, xml ) {
var cache, uniqueCache, outerCache, node, nodeIndex, start,
dir = simple !== forward ? "nextSibling" : "previousSibling",
parent = elem.parentNode,
name = ofType && elem.nodeName.toLowerCase(),
useCache = !xml && !ofType,
diff = false;
if ( parent ) {
// :(first|last|only)-(child|of-type)
if ( simple ) {
while ( dir ) {
node = elem;
while ( (node = node[ dir ]) ) {
if ( ofType ?
node.nodeName.toLowerCase() === name :
node.nodeType === 1 ) {
return false;
}
}
// Reverse direction for :only-* (if we haven't yet done so)
start = dir = type === "only" && !start && "nextSibling";
}
return true;
}
start = [ forward ? parent.firstChild : parent.lastChild ];
// non-xml :nth-child(...) stores cache data on `parent`
if ( forward && useCache ) {
// Seek `elem` from a previously-cached index
// ...in a gzip-friendly way
node = parent;
outerCache = node[ expando ] || (node[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ node.uniqueID ] ||
(outerCache[ node.uniqueID ] = {});
cache = uniqueCache[ type ] || [];
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
diff = nodeIndex && cache[ 2 ];
node = nodeIndex && parent.childNodes[ nodeIndex ];
while ( (node = ++nodeIndex && node && node[ dir ] ||
// Fallback to seeking `elem` from the start
(diff = nodeIndex = 0) || start.pop()) ) {
// When found, cache indexes on `parent` and break
if ( node.nodeType === 1 && ++diff && node === elem ) {
uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
break;
}
}
} else {
// Use previously-cached element index if available
if ( useCache ) {
// ...in a gzip-friendly way
node = elem;
outerCache = node[ expando ] || (node[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ node.uniqueID ] ||
(outerCache[ node.uniqueID ] = {});
cache = uniqueCache[ type ] || [];
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
diff = nodeIndex;
}
// xml :nth-child(...)
// or :nth-last-child(...) or :nth(-last)?-of-type(...)
if ( diff === false ) {
// Use the same loop as above to seek `elem` from the start
while ( (node = ++nodeIndex && node && node[ dir ] ||
(diff = nodeIndex = 0) || start.pop()) ) {
if ( ( ofType ?
node.nodeName.toLowerCase() === name :
node.nodeType === 1 ) &&
++diff ) {
// Cache the index of each encountered element
if ( useCache ) {
outerCache = node[ expando ] || (node[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ node.uniqueID ] ||
(outerCache[ node.uniqueID ] = {});
uniqueCache[ type ] = [ dirruns, diff ];
}
if ( node === elem ) {
break;
}
}
}
}
}
// Incorporate the offset, then check against cycle size
diff -= last;
return diff === first || ( diff % first === 0 && diff / first >= 0 );
}
};
},
"PSEUDO": function( pseudo, argument ) {
// pseudo-class names are case-insensitive
// http://www.w3.org/TR/selectors/#pseudo-classes
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
// Remember that setFilters inherits from pseudos
var args,
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
Sizzle.error( "unsupported pseudo: " + pseudo );
// The user may use createPseudo to indicate that
// arguments are needed to create the filter function
// just as Sizzle does
if ( fn[ expando ] ) {
return fn( argument );
}
// But maintain support for old signatures
if ( fn.length > 1 ) {
args = [ pseudo, pseudo, "", argument ];
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
markFunction(function( seed, matches ) {
var idx,
matched = fn( seed, argument ),
i = matched.length;
while ( i-- ) {
idx = indexOf( seed, matched[i] );
seed[ idx ] = !( matches[ idx ] = matched[i] );
}
}) :
function( elem ) {
return fn( elem, 0, args );
};
}
return fn;
}
},
pseudos: {
// Potentially complex pseudos
"not": markFunction(function( selector ) {
// Trim the selector passed to compile
// to avoid treating leading and trailing
// spaces as combinators
var input = [],
results = [],
matcher = compile( selector.replace( rtrim, "$1" ) );
return matcher[ expando ] ?
markFunction(function( seed, matches, context, xml ) {
var elem,
unmatched = matcher( seed, null, xml, [] ),
i = seed.length;
// Match elements unmatched by `matcher`
while ( i-- ) {
if ( (elem = unmatched[i]) ) {
seed[i] = !(matches[i] = elem);
}
}
}) :
function( elem, context, xml ) {
input[0] = elem;
matcher( input, null, xml, results );
// Don't keep the element (issue #299)
input[0] = null;
return !results.pop();
};
}),
"has": markFunction(function( selector ) {
return function( elem ) {
return Sizzle( selector, elem ).length > 0;
};
}),
"contains": markFunction(function( text ) {
text = text.replace( runescape, funescape );
return function( elem ) {
return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
};
}),
// "Whether an element is represented by a :lang() selector
// is based solely on the element's language value
// being equal to the identifier C,
// or beginning with the identifier C immediately followed by "-".
// The matching of C against the element's language value is performed case-insensitively.
// The identifier C does not have to be a valid language name."
// http://www.w3.org/TR/selectors/#lang-pseudo
"lang": markFunction( function( lang ) {
// lang value must be a valid identifier
if ( !ridentifier.test(lang || "") ) {
Sizzle.error( "unsupported lang: " + lang );
}
lang = lang.replace( runescape, funescape ).toLowerCase();
return function( elem ) {
var elemLang;
do {
if ( (elemLang = documentIsHTML ?
elem.lang :
elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
elemLang = elemLang.toLowerCase();
return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
}
} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
return false;
};
}),
// Miscellaneous
"target": function( elem ) {
var hash = window.location && window.location.hash;
return hash && hash.slice( 1 ) === elem.id;
},
"root": function( elem ) {
return elem === docElem;
},
"focus": function( elem ) {
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
},
// Boolean properties
"enabled": createDisabledPseudo( false ),
"disabled": createDisabledPseudo( true ),
"checked": function( elem ) {
// In CSS3, :checked should return both checked and selected elements
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
var nodeName = elem.nodeName.toLowerCase();
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
},
"selected": function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
if ( elem.parentNode ) {
elem.parentNode.selectedIndex;
}
return elem.selected === true;
},
// Contents
"empty": function( elem ) {
// http://www.w3.org/TR/selectors/#empty-pseudo
// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
// but not by others (comment: 8; processing instruction: 7; etc.)
// nodeType < 6 works because attributes (2) do not appear as children
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
if ( elem.nodeType < 6 ) {
return false;
}
}
return true;
},
"parent": function( elem ) {
return !Expr.pseudos["empty"]( elem );
},
// Element/input types
"header": function( elem ) {
return rheader.test( elem.nodeName );
},
"input": function( elem ) {
return rinputs.test( elem.nodeName );
},
"button": function( elem ) {
var name = elem.nodeName.toLowerCase();
return name === "input" && elem.type === "button" || name === "button";
},
"text": function( elem ) {
var attr;
return elem.nodeName.toLowerCase() === "input" &&
elem.type === "text" &&
// Support: IE<8
// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
},
// Position-in-collection
"first": createPositionalPseudo(function() {
return [ 0 ];
}),
"last": createPositionalPseudo(function( matchIndexes, length ) {
return [ length - 1 ];
}),
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
return [ argument < 0 ? argument + length : argument ];
}),
"even": createPositionalPseudo(function( matchIndexes, length ) {
var i = 0;
for ( ; i < length; i += 2 ) {
matchIndexes.push( i );
}
return matchIndexes;
}),
"odd": createPositionalPseudo(function( matchIndexes, length ) {
var i = 1;
for ( ; i < length; i += 2 ) {
matchIndexes.push( i );
}
return matchIndexes;
}),
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
var i = argument < 0 ?
argument + length :
argument > length ?
length :
argument;
for ( ; --i >= 0; ) {
matchIndexes.push( i );
}
return matchIndexes;
}),
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
var i = argument < 0 ? argument + length : argument;
for ( ; ++i < length; ) {
matchIndexes.push( i );
}
return matchIndexes;
})
}
};
Expr.pseudos["nth"] = Expr.pseudos["eq"];
// Add button/input type pseudos
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
Expr.pseudos[ i ] = createInputPseudo( i );
}
for ( i in { submit: true, reset: true } ) {
Expr.pseudos[ i ] = createButtonPseudo( i );
}
// Easy API for creating new setFilters
function setFilters() {}
setFilters.prototype = Expr.filters = Expr.pseudos;
Expr.setFilters = new setFilters();
tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
var matched, match, tokens, type,
soFar, groups, preFilters,
cached = tokenCache[ selector + " " ];
if ( cached ) {
return parseOnly ? 0 : cached.slice( 0 );
}
soFar = selector;
groups = [];
preFilters = Expr.preFilter;
while ( soFar ) {
// Comma and first run
if ( !matched || (match = rcomma.exec( soFar )) ) {
if ( match ) {
// Don't consume trailing commas as valid
soFar = soFar.slice( match[0].length ) || soFar;
}
groups.push( (tokens = []) );
}
matched = false;
// Combinators
if ( (match = rcombinators.exec( soFar )) ) {
matched = match.shift();
tokens.push({
value: matched,
// Cast descendant combinators to space
type: match[0].replace( rtrim, " " )
});
soFar = soFar.slice( matched.length );
}
// Filters
for ( type in Expr.filter ) {
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
(match = preFilters[ type ]( match ))) ) {
matched = match.shift();
tokens.push({
value: matched,
type: type,
matches: match
});
soFar = soFar.slice( matched.length );
}
}
if ( !matched ) {
break;
}
}
// Return the length of the invalid excess
// if we're just parsing
// Otherwise, throw an error or return tokens
return parseOnly ?
soFar.length :
soFar ?
Sizzle.error( selector ) :
// Cache the tokens
tokenCache( selector, groups ).slice( 0 );
};
function toSelector( tokens ) {
var i = 0,
len = tokens.length,
selector = "";
for ( ; i < len; i++ ) {
selector += tokens[i].value;
}
return selector;
}
function addCombinator( matcher, combinator, base ) {
var dir = combinator.dir,
skip = combinator.next,
key = skip || dir,
checkNonElements = base && key === "parentNode",
doneName = done++;
return combinator.first ?
// Check against closest ancestor/preceding element
function( elem, context, xml ) {
while ( (elem = elem[ dir ]) ) {
if ( elem.nodeType === 1 || checkNonElements ) {
return matcher( elem, context, xml );
}
}
return false;
} :
// Check against all ancestor/preceding elements
function( elem, context, xml ) {
var oldCache, uniqueCache, outerCache,
newCache = [ dirruns, doneName ];
// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
if ( xml ) {
while ( (elem = elem[ dir ]) ) {
if ( elem.nodeType === 1 || checkNonElements ) {
if ( matcher( elem, context, xml ) ) {
return true;
}
}
}
} else {
while ( (elem = elem[ dir ]) ) {
if ( elem.nodeType === 1 || checkNonElements ) {
outerCache = elem[ expando ] || (elem[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
if ( skip && skip === elem.nodeName.toLowerCase() ) {
elem = elem[ dir ] || elem;
} else if ( (oldCache = uniqueCache[ key ]) &&
oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
// Assign to newCache so results back-propagate to previous elements
return (newCache[ 2 ] = oldCache[ 2 ]);
} else {
// Reuse newcache so results back-propagate to previous elements
uniqueCache[ key ] = newCache;
// A match means we're done; a fail means we have to keep checking
if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
return true;
}
}
}
}
}
return false;
};
}
function elementMatcher( matchers ) {
return matchers.length > 1 ?
function( elem, context, xml ) {
var i = matchers.length;
while ( i-- ) {
if ( !matchers[i]( elem, context, xml ) ) {
return false;
}
}
return true;
} :
matchers[0];
}
function multipleContexts( selector, contexts, results ) {
var i = 0,
len = contexts.length;
for ( ; i < len; i++ ) {
Sizzle( selector, contexts[i], results );
}
return results;
}
function condense( unmatched, map, filter, context, xml ) {
var elem,
newUnmatched = [],
i = 0,
len = unmatched.length,
mapped = map != null;
for ( ; i < len; i++ ) {
if ( (elem = unmatched[i]) ) {
if ( !filter || filter( elem, context, xml ) ) {
newUnmatched.push( elem );
if ( mapped ) {
map.push( i );
}
}
}
}
return newUnmatched;
}
function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
if ( postFilter && !postFilter[ expando ] ) {
postFilter = setMatcher( postFilter );
}
if ( postFinder && !postFinder[ expando ] ) {
postFinder = setMatcher( postFinder, postSelector );
}
return markFunction(function( seed, results, context, xml ) {
var temp, i, elem,
preMap = [],
postMap = [],
preexisting = results.length,
// Get initial elements from seed or context
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
// Prefilter to get matcher input, preserving a map for seed-results synchronization
matcherIn = preFilter && ( seed || !selector ) ?
condense( elems, preMap, preFilter, context, xml ) :
elems,
matcherOut = matcher ?
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
// ...intermediate processing is necessary
[] :
// ...otherwise use results directly
results :
matcherIn;
// Find primary matches
if ( matcher ) {
matcher( matcherIn, matcherOut, context, xml );
}
// Apply postFilter
if ( postFilter ) {
temp = condense( matcherOut, postMap );
postFilter( temp, [], context, xml );
// Un-match failing elements by moving them back to matcherIn
i = temp.length;
while ( i-- ) {
if ( (elem = temp[i]) ) {
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
}
}
}
if ( seed ) {
if ( postFinder || preFilter ) {
if ( postFinder ) {
// Get the final matcherOut by condensing this intermediate into postFinder contexts
temp = [];
i = matcherOut.length;
while ( i-- ) {
if ( (elem = matcherOut[i]) ) {
// Restore matcherIn since elem is not yet a final match
temp.push( (matcherIn[i] = elem) );
}
}
postFinder( null, (matcherOut = []), temp, xml );
}
// Move matched elements from seed to results to keep them synchronized
i = matcherOut.length;
while ( i-- ) {
if ( (elem = matcherOut[i]) &&
(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
seed[temp] = !(results[temp] = elem);
}
}
}
// Add elements to results, through postFinder if defined
} else {
matcherOut = condense(
matcherOut === results ?
matcherOut.splice( preexisting, matcherOut.length ) :
matcherOut
);
if ( postFinder ) {
postFinder( null, results, matcherOut, xml );
} else {
push.apply( results, matcherOut );
}
}
});
}
function matcherFromTokens( tokens ) {
var checkContext, matcher, j,
len = tokens.length,
leadingRelative = Expr.relative[ tokens[0].type ],
implicitRelative = leadingRelative || Expr.relative[" "],
i = leadingRelative ? 1 : 0,
// The foundational matcher ensures that elements are reachable from top-level context(s)
matchContext = addCombinator( function( elem ) {
return elem === checkContext;
}, implicitRelative, true ),
matchAnyContext = addCombinator( function( elem ) {
return indexOf( checkContext, elem ) > -1;
}, implicitRelative, true ),
matchers = [ function( elem, context, xml ) {
var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
(checkContext = context).nodeType ?
matchContext( elem, context, xml ) :
matchAnyContext( elem, context, xml ) );
// Avoid hanging onto element (issue #299)
checkContext = null;
return ret;
} ];
for ( ; i < len; i++ ) {
if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
} else {
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
// Return special upon seeing a positional matcher
if ( matcher[ expando ] ) {
// Find the next relative operator (if any) for proper handling
j = ++i;
for ( ; j < len; j++ ) {
if ( Expr.relative[ tokens[j].type ] ) {
break;
}
}
return setMatcher(
i > 1 && elementMatcher( matchers ),
i > 1 && toSelector(
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
).replace( rtrim, "$1" ),
matcher,
i < j && matcherFromTokens( tokens.slice( i, j ) ),
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
j < len && toSelector( tokens )
);
}
matchers.push( matcher );
}
}
return elementMatcher( matchers );
}
function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
var bySet = setMatchers.length > 0,
byElement = elementMatchers.length > 0,
superMatcher = function( seed, context, xml, results, outermost ) {
var elem, j, matcher,
matchedCount = 0,
i = "0",
unmatched = seed && [],
setMatched = [],
contextBackup = outermostContext,
// We must always have either seed elements or outermost context
elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
// Use integer dirruns iff this is the outermost matcher
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
len = elems.length;
if ( outermost ) {
outermostContext = context === document || context || outermost;
}
// Add elements passing elementMatchers directly to results
// Support: IE<9, Safari
// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
if ( byElement && elem ) {
j = 0;
if ( !context && elem.ownerDocument !== document ) {
setDocument( elem );
xml = !documentIsHTML;
}
while ( (matcher = elementMatchers[j++]) ) {
if ( matcher( elem, context || document, xml) ) {
results.push( elem );
break;
}
}
if ( outermost ) {
dirruns = dirrunsUnique;
}
}
// Track unmatched elements for set filters
if ( bySet ) {
// They will have gone through all possible matchers
if ( (elem = !matcher && elem) ) {
matchedCount--;
}
// Lengthen the array for every element, matched or not
if ( seed ) {
unmatched.push( elem );
}
}
}
// `i` is now the count of elements visited above, and adding it to `matchedCount`
// makes the latter nonnegative.
matchedCount += i;
// Apply set filters to unmatched elements
// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
// no element matchers and no seed.
// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
// case, which will result in a "00" `matchedCount` that differs from `i` but is also
// numerically zero.
if ( bySet && i !== matchedCount ) {
j = 0;
while ( (matcher = setMatchers[j++]) ) {
matcher( unmatched, setMatched, context, xml );
}
if ( seed ) {
// Reintegrate element matches to eliminate the need for sorting
if ( matchedCount > 0 ) {
while ( i-- ) {
if ( !(unmatched[i] || setMatched[i]) ) {
setMatched[i] = pop.call( results );
}
}
}
// Discard index placeholder values to get only actual matches
setMatched = condense( setMatched );
}
// Add matches to results
push.apply( results, setMatched );
// Seedless set matches succeeding multiple successful matchers stipulate sorting
if ( outermost && !seed && setMatched.length > 0 &&
( matchedCount + setMatchers.length ) > 1 ) {
Sizzle.uniqueSort( results );
}
}
// Override manipulation of globals by nested matchers
if ( outermost ) {
dirruns = dirrunsUnique;
outermostContext = contextBackup;
}
return unmatched;
};
return bySet ?
markFunction( superMatcher ) :
superMatcher;
}
compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
var i,
setMatchers = [],
elementMatchers = [],
cached = compilerCache[ selector + " " ];
if ( !cached ) {
// Generate a function of recursive functions that can be used to check each element
if ( !match ) {
match = tokenize( selector );
}
i = match.length;
while ( i-- ) {
cached = matcherFromTokens( match[i] );
if ( cached[ expando ] ) {
setMatchers.push( cached );
} else {
elementMatchers.push( cached );
}
}
// Cache the compiled function
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
// Save selector and tokenization
cached.selector = selector;
}
return cached;
};
/**
* A low-level selection function that works with Sizzle's compiled
* selector functions
* @param {String|Function} selector A selector or a pre-compiled
* selector function built with Sizzle.compile
* @param {Element} context
* @param {Array} [results]
* @param {Array} [seed] A set of elements to match against
*/
select = Sizzle.select = function( selector, context, results, seed ) {
var i, tokens, token, type, find,
compiled = typeof selector === "function" && selector,
match = !seed && tokenize( (selector = compiled.selector || selector) );
results = results || [];
// Try to minimize operations if there is only one selector in the list and no seed
// (the latter of which guarantees us context)
if ( match.length === 1 ) {
// Reduce context if the leading compound selector is an ID
tokens = match[0] = match[0].slice( 0 );
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
if ( !context ) {
return results;
// Precompiled matchers will still verify ancestry, so step up a level
} else if ( compiled ) {
context = context.parentNode;
}
selector = selector.slice( tokens.shift().value.length );
}
// Fetch a seed set for right-to-left matching
i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
while ( i-- ) {
token = tokens[i];
// Abort if we hit a combinator
if ( Expr.relative[ (type = token.type) ] ) {
break;
}
if ( (find = Expr.find[ type ]) ) {
// Search, expanding context for leading sibling combinators
if ( (seed = find(
token.matches[0].replace( runescape, funescape ),
rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
)) ) {
// If seed is empty or no tokens remain, we can return early
tokens.splice( i, 1 );
selector = seed.length && toSelector( tokens );
if ( !selector ) {
push.apply( results, seed );
return results;
}
break;
}
}
}
}
// Compile and execute a filtering function if one is not provided
// Provide `match` to avoid retokenization if we modified the selector above
( compiled || compile( selector, match ) )(
seed,
context,
!documentIsHTML,
results,
!context || rsibling.test( selector ) && testContext( context.parentNode ) || context
);
return results;
};
// One-time assignments
// Sort stability
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
// Support: Chrome 14-35+
// Always assume duplicates if they aren't passed to the comparison function
support.detectDuplicates = !!hasDuplicate;
// Initialize against the default document
setDocument();
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
// Detached nodes confoundingly follow *each other*
support.sortDetached = assert(function( el ) {
// Should return 1, but returns 4 (following)
return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
});
// Support: IE<8
// Prevent attribute/property "interpolation"
// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !assert(function( el ) {
el.innerHTML = "<a href='#'></a>";
return el.firstChild.getAttribute("href") === "#" ;
}) ) {
addHandle( "type|href|height|width", function( elem, name, isXML ) {
if ( !isXML ) {
return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
}
});
}
// Support: IE<9
// Use defaultValue in place of getAttribute("value")
if ( !support.attributes || !assert(function( el ) {
el.innerHTML = "<input/>";
el.firstChild.setAttribute( "value", "" );
return el.firstChild.getAttribute( "value" ) === "";
}) ) {
addHandle( "value", function( elem, name, isXML ) {
if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
return elem.defaultValue;
}
});
}
// Support: IE<9
// Use getAttributeNode to fetch booleans when getAttribute lies
if ( !assert(function( el ) {
return el.getAttribute("disabled") == null;
}) ) {
addHandle( booleans, function( elem, name, isXML ) {
var val;
if ( !isXML ) {
return elem[ name ] === true ? name.toLowerCase() :
(val = elem.getAttributeNode( name )) && val.specified ?
val.value :
null;
}
});
}
return Sizzle;
})( window );
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
// Deprecated
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;
jQuery.escapeSelector = Sizzle.escape;
var dir = function( elem, dir, until ) {
var matched = [],
truncate = until !== undefined;
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) {
break;
}
matched.push( elem );
}
}
return matched;
};
var siblings = function( n, elem ) {
var matched = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
matched.push( n );
}
}
return matched;
};
var rneedsContext = jQuery.expr.match.needsContext;
function nodeName( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
};
var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
if ( isFunction( qualifier ) ) {
return jQuery.grep( elements, function( elem, i ) {
return !!qualifier.call( elem, i, elem ) !== not;
} );
}
// Single element
if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not;
} );
}
// Arraylike of elements (jQuery, arguments, Array)
if ( typeof qualifier !== "string" ) {
return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
} );
}
// Filtered directly for both simple and complex selectors
return jQuery.filter( qualifier, elements, not );
}
jQuery.filter = function( expr, elems, not ) {
var elem = elems[ 0 ];
if ( not ) {
expr = ":not(" + expr + ")";
}
if ( elems.length === 1 && elem.nodeType === 1 ) {
return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
}
return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1;
} ) );
};
jQuery.fn.extend( {
find: function( selector ) {
var i, ret,
len = this.length,
self = this;
if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter( function() {
for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) {
return true;
}
}
} ) );
}
ret = this.pushStack( [] );
for ( i = 0; i < len; i++ ) {
jQuery.find( selector, self[ i ], ret );
}
return len > 1 ? jQuery.uniqueSort( ret ) : ret;
},
filter: function( selector ) {
return this.pushStack( winnow( this, selector || [], false ) );
},
not: function( selector ) {
return this.pushStack( winnow( this, selector || [], true ) );
},
is: function( selector ) {
return !!winnow(
this,
// If this is a positional/relative selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p".
typeof selector === "string" && rneedsContext.test( selector ) ?
jQuery( selector ) :
selector || [],
false
).length;
}
} );
// Initialize a jQuery object
// A central reference to the root jQuery(document)
var rootjQuery,
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
// Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context, root ) {
var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false)
if ( !selector ) {
return this;
}
// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
// Handle HTML strings
if ( typeof selector === "string" ) {
if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
selector.length >= 3 ) {
// Assume that strings that start and end with <> are HTML and skip the regex check
match = [ null, selector, null ];
} else {
match = rquickExpr.exec( selector );
}
// Match html or make sure no context is specified for #id
if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array)
if ( match[ 1 ] ) {
context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML(
match[ 1 ],
context && context.nodeType ? context.ownerDocument || context : document,
true
) );
// HANDLE: $(html, props)
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
// Properties of context are called as methods if possible
if ( isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
// ...and otherwise set as attributes
} else {
this.attr( match, context[ match ] );
}
}
}
return this;
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[ 2 ] );
if ( elem ) {
// Inject the element directly into the jQuery object
this[ 0 ] = elem;
this.length = 1;
}
return this;
}
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || root ).find( selector );
// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
} else {
return this.constructor( context ).find( selector );
}
// HANDLE: $(DOMElement)
} else if ( selector.nodeType ) {
this[ 0 ] = selector;
this.length = 1;
return this;
// HANDLE: $(function)
// Shortcut for document ready
} else if ( isFunction( selector ) ) {
return root.ready !== undefined ?
root.ready( selector ) :
// Execute immediately if ready is not present
selector( jQuery );
}
return jQuery.makeArray( selector, this );
};
// Give the init function the jQuery prototype for later instantiation
init.prototype = jQuery.fn;
// Initialize central reference
rootjQuery = jQuery( document );
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
contents: true,
next: true,
prev: true
};
jQuery.fn.extend( {
has: function( target ) {
var targets = jQuery( target, this ),
l = targets.length;
return this.filter( function() {
var i = 0;
for ( ; i < l; i++ ) {
if ( jQuery.contains( this, targets[ i ] ) ) {
return true;
}
}
} );
},
closest: function( selectors, context ) {
var cur,
i = 0,
l = this.length,
matched = [],
targets = typeof selectors !== "string" && jQuery( selectors );
// Positional selectors never match, since there's no _selection_ context
if ( !rneedsContext.test( selectors ) ) {
for ( ; i < l; i++ ) {
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments
if ( cur.nodeType < 11 && ( targets ?
targets.index( cur ) > -1 :
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
jQuery.find.matchesSelector( cur, selectors ) ) ) {
matched.push( cur );
break;
}
}
}
}
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
},
// Determine the position of an element within the set
index: function( elem ) {
// No argument, return index in parent
if ( !elem ) {
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
}
// Index in selector
if ( typeof elem === "string" ) {
return indexOf.call( jQuery( elem ), this[ 0 ] );
}
// Locate the position of the desired element
return indexOf.call( this,
// If it receives a jQuery object, the first element is used
elem.jquery ? elem[ 0 ] : elem
);
},
add: function( selector, context ) {
return this.pushStack(
jQuery.uniqueSort(
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
},
addBack: function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter( selector )
);
}
} );
function sibling( cur, dir ) {
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
return cur;
}
jQuery.each( {
parent: function( elem ) {
var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null;
},
parents: function( elem ) {
return dir( elem, "parentNode" );
},
parentsUntil: function( elem, i, until ) {
return dir( elem, "parentNode", until );
},
next: function( elem ) {
return sibling( elem, "nextSibling" );
},
prev: function( elem ) {
return sibling( elem, "previousSibling" );
},
nextAll: function( elem ) {
return dir( elem, "nextSibling" );
},
prevAll: function( elem ) {
return dir( elem, "previousSibling" );
},
nextUntil: function( elem, i, until ) {
return dir( elem, "nextSibling", until );
},
prevUntil: function( elem, i, until ) {
return dir( elem, "previousSibling", until );
},
siblings: function( elem ) {
return siblings( ( elem.parentNode || {} ).firstChild, elem );
},
children: function( elem ) {
return siblings( elem.firstChild );
},
contents: function( elem ) {
if ( typeof elem.contentDocument !== "undefined" ) {
return elem.contentDocument;
}
// Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
// Treat the template element as a regular one in browsers that
// don't support it.
if ( nodeName( elem, "template" ) ) {
elem = elem.content || elem;
}
return jQuery.merge( [], elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
var matched = jQuery.map( this, fn, until );
if ( name.slice( -5 ) !== "Until" ) {
selector = until;
}
if ( selector && typeof selector === "string" ) {
matched = jQuery.filter( selector, matched );
}
if ( this.length > 1 ) {
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
jQuery.uniqueSort( matched );
}
// Reverse order for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) {
matched.reverse();
}
}
return this.pushStack( matched );
};
} );
var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
// Convert String-formatted options into Object-formatted ones
function createOptions( options ) {
var object = {};
jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
object[ flag ] = true;
} );
return object;
}
/*
* Create a callback list using the following parameters:
*
* options: an optional list of space-separated options that will change how
* the callback list behaves or a more traditional option object
*
* By default a callback list will act like an event callback list and can be
* "fired" multiple times.
*
* Possible options:
*
* once: will ensure the callback list can only be fired once (like a Deferred)
*
* memory: will keep track of previous values and will call any callback added
* after the list has been fired right away with the latest "memorized"
* values (like a Deferred)
*
* unique: will ensure a callback can only be added once (no duplicate in the list)
*
* stopOnFalse: interrupt callings when a callback returns false
*
*/
jQuery.Callbacks = function( options ) {
// Convert options from String-formatted to Object-formatted if needed
// (we check in cache first)
options = typeof options === "string" ?
createOptions( options ) :
jQuery.extend( {}, options );
var // Flag to know if list is currently firing
firing,
// Last fire value for non-forgettable lists
memory,
// Flag to know if list was already fired
fired,
// Flag to prevent firing
locked,
// Actual callback list
list = [],
// Queue of execution data for repeatable lists
queue = [],
// Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1,
// Fire callbacks
fire = function() {
// Enforce single-firing
locked = locked || options.once;
// Execute callbacks for all pending executions,
// respecting firingIndex overrides and runtime changes
fired = firing = true;
for ( ; queue.length; firingIndex = -1 ) {
memory = queue.shift();
while ( ++firingIndex < list.length ) {
// Run callback and check for early termination
if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
options.stopOnFalse ) {
// Jump to end and forget the data so .add doesn't re-fire
firingIndex = list.length;
memory = false;
}
}
}
// Forget the data if we're done with it
if ( !options.memory ) {
memory = false;
}
firing = false;
// Clean up if we're done firing for good
if ( locked ) {
// Keep an empty list if we have data for future add calls
if ( memory ) {
list = [];
// Otherwise, this object is spent
} else {
list = "";
}
}
},
// Actual Callbacks object
self = {
// Add a callback or a collection of callbacks to the list
add: function() {
if ( list ) {
// If we have memory from a past run, we should fire after adding
if ( memory && !firing ) {
firingIndex = list.length - 1;
queue.push( memory );
}
( function add( args ) {
jQuery.each( args, function( _, arg ) {
if ( isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) {
list.push( arg );
}
} else if ( arg && arg.length && toType( arg ) !== "string" ) {
// Inspect recursively
add( arg );
}
} );
} )( arguments );
if ( memory && !firing ) {
fire();
}
}
return this;
},
// Remove a callback from the list
remove: function() {
jQuery.each( arguments, function( _, arg ) {
var index;
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
list.splice( index, 1 );
// Handle firing indexes
if ( index <= firingIndex ) {
firingIndex--;
}
}
} );
return this;
},
// Check if a given callback is in the list.
// If no argument is given, return whether or not list has callbacks attached.
has: function( fn ) {
return fn ?
jQuery.inArray( fn, list ) > -1 :
list.length > 0;
},
// Remove all callbacks from the list
empty: function() {
if ( list ) {
list = [];
}
return this;
},
// Disable .fire and .add
// Abort any current/pending executions
// Clear all callbacks and values
disable: function() {
locked = queue = [];
list = memory = "";
return this;
},
disabled: function() {
return !list;
},
// Disable .fire
// Also disable .add unless we have memory (since it would have no effect)
// Abort any pending executions
lock: function() {
locked = queue = [];
if ( !memory && !firing ) {
list = memory = "";
}
return this;
},
locked: function() {
return !!locked;
},
// Call all callbacks with the given context and arguments
fireWith: function( context, args ) {
if ( !locked ) {
args = args || [];
args = [ context, args.slice ? args.slice() : args ];
queue.push( args );
if ( !firing ) {
fire();
}
}
return this;
},
// Call all the callbacks with the given arguments
fire: function() {
self.fireWith( this, arguments );
return this;
},
// To know if the callbacks have already been called at least once
fired: function() {
return !!fired;
}
};
return self;
};
function Identity( v ) {
return v;
}
function Thrower( ex ) {
throw ex;
}
function adoptValue( value, resolve, reject, noValue ) {
var method;
try {
// Check for promise aspect first to privilege synchronous behavior
if ( value && isFunction( ( method = value.promise ) ) ) {
method.call( value ).done( resolve ).fail( reject );
// Other thenables
} else if ( value && isFunction( ( method = value.then ) ) ) {
method.call( value, resolve, reject );
// Other non-thenables
} else {
// Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
// * false: [ value ].slice( 0 ) => resolve( value )
// * true: [ value ].slice( 1 ) => resolve()
resolve.apply( undefined, [ value ].slice( noValue ) );
}
// For Promises/A+, convert exceptions into rejections
// Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
// Deferred#then to conditionally suppress rejection.
} catch ( value ) {
// Support: Android 4.0 only
// Strict mode functions invoked without .call/.apply get global-object context
reject.apply( undefined, [ value ] );
}
}
jQuery.extend( {
Deferred: function( func ) {
var tuples = [
// action, add listener, callbacks,
// ... .then handlers, argument index, [final state]
[ "notify", "progress", jQuery.Callbacks( "memory" ),
jQuery.Callbacks( "memory" ), 2 ],
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
],
state = "pending",
promise = {
state: function() {
return state;
},
always: function() {
deferred.done( arguments ).fail( arguments );
return this;
},
"catch": function( fn ) {
return promise.then( null, fn );
},
// Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && isFunction( returned.promise ) ) {
returned.promise()
.progress( newDefer.notify )
.done( newDefer.resolve )
.fail( newDefer.reject );
} else {
newDefer[ tuple[ 0 ] + "With" ](
this,
fn ? [ returned ] : arguments
);
}
} );
} );
fns = null;
} ).promise();
},
then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0;
function resolve( depth, deferred, handler, special ) {
return function() {
var that = this,
args = arguments,
mightThrow = function() {
var returned, then;
// Support: Promises/A+ section 2.3.3.3.3
// https://promisesaplus.com/#point-59
// Ignore double-resolution attempts
if ( depth < maxDepth ) {
return;
}
returned = handler.apply( that, args );
// Support: Promises/A+ section 2.3.1
// https://promisesaplus.com/#point-48
if ( returned === deferred.promise() ) {
throw new TypeError( "Thenable self-resolution" );
}
// Support: Promises/A+ sections 2.3.3.1, 3.5
// https://promisesaplus.com/#point-54
// https://promisesaplus.com/#point-75
// Retrieve `then` only once
then = returned &&
// Support: Promises/A+ section 2.3.4
// https://promisesaplus.com/#point-64
// Only check objects and functions for thenability
( typeof returned === "object" ||
typeof returned === "function" ) &&
returned.then;
// Handle a returned thenable
if ( isFunction( then ) ) {
// Special processors (notify) just wait for resolution
if ( special ) {
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special )
);
// Normal processors (resolve) also hook into progress
} else {
// ...and disregard older resolution values
maxDepth++;
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special ),
resolve( maxDepth, deferred, Identity,
deferred.notifyWith )
);
}
// Handle all other returned values
} else {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Identity ) {
that = undefined;
args = [ returned ];
}
// Process the value(s)
// Default process is resolve
( special || deferred.resolveWith )( that, args );
}
},
// Only normal processors (resolve) catch and reject exceptions
process = special ?
mightThrow :
function() {
try {
mightThrow();
} catch ( e ) {
if ( jQuery.Deferred.exceptionHook ) {
jQuery.Deferred.exceptionHook( e,
process.stackTrace );
}
// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Thrower ) {
that = undefined;
args = [ e ];
}
deferred.rejectWith( that, args );
}
}
};
// Support: Promises/A+ section 2.3.3.3.1
// https://promisesaplus.com/#point-57
// Re-resolve promises immediately to dodge false rejection from
// subsequent errors
if ( depth ) {
process();
} else {
// Call an optional hook to record the stack, in case of exception
// since it's otherwise lost when execution goes async
if ( jQuery.Deferred.getStackHook ) {
process.stackTrace = jQuery.Deferred.getStackHook();
}
window.setTimeout( process );
}
};
}
return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add(
resolve(
0,
newDefer,
isFunction( onProgress ) ?
onProgress :
Identity,
newDefer.notifyWith
)
);
// fulfilled_handlers.add( ... )
tuples[ 1 ][ 3 ].add(
resolve(
0,
newDefer,
isFunction( onFulfilled ) ?
onFulfilled :
Identity
)
);
// rejected_handlers.add( ... )
tuples[ 2 ][ 3 ].add(
resolve(
0,
newDefer,
isFunction( onRejected ) ?
onRejected :
Thrower
)
);
} ).promise();
},
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
return obj != null ? jQuery.extend( obj, promise ) : promise;
}
},
deferred = {};
// Add list-specific methods
jQuery.each( tuples, function( i, tuple ) {
var list = tuple[ 2 ],
stateString = tuple[ 5 ];
// promise.progress = list.add
// promise.done = list.add
// promise.fail = list.add
promise[ tuple[ 1 ] ] = list.add;
// Handle state
if ( stateString ) {
list.add(
function() {
// state = "resolved" (i.e., fulfilled)
// state = "rejected"
state = stateString;
},
// rejected_callbacks.disable
// fulfilled_callbacks.disable
tuples[ 3 - i ][ 2 ].disable,
// rejected_handlers.disable
// fulfilled_handlers.disable
tuples[ 3 - i ][ 3 ].disable,
// progress_callbacks.lock
tuples[ 0 ][ 2 ].lock,
// progress_handlers.lock
tuples[ 0 ][ 3 ].lock
);
}
// progress_handlers.fire
// fulfilled_handlers.fire
// rejected_handlers.fire
list.add( tuple[ 3 ].fire );
// deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
return this;
};
// deferred.notifyWith = list.fireWith
// deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
} );
// Make the deferred a promise
promise.promise( deferred );
// Call given func if any
if ( func ) {
func.call( deferred, deferred );
}
// All done!
return deferred;
},
// Deferred helper
when: function( singleValue ) {
var
// count of uncompleted subordinates
remaining = arguments.length,
// count of unprocessed arguments
i = remaining,
// subordinate fulfillment data
resolveContexts = Array( i ),
resolveValues = slice.call( arguments ),
// the master Deferred
master = jQuery.Deferred(),
// subordinate callback factory
updateFunc = function( i ) {
return function( value ) {
resolveContexts[ i ] = this;
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( !( --remaining ) ) {
master.resolveWith( resolveContexts, resolveValues );
}
};
};
// Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) {
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
!remaining );
// Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( master.state() === "pending" ||
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
return master.then();
}
}
// Multiple arguments are aggregated like Promise.all array elements
while ( i-- ) {
adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
}
return master.promise();
}
} );
// These usually indicate a programmer mistake during development,
// warn about them ASAP rather than swallowing them by default.
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
jQuery.Deferred.exceptionHook = function( error, stack ) {
// Support: IE 8 - 9 only
// Console exists when dev tools are open, which can happen at any time
if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
}
};
jQuery.readyException = function( error ) {
window.setTimeout( function() {
throw error;
} );
};
// The deferred used on DOM ready
var readyList = jQuery.Deferred();
jQuery.fn.ready = function( fn ) {
readyList
.then( fn )
// Wrap jQuery.readyException in a function so that the lookup
// happens at the time of error handling instead of callback
// registration.
.catch( function( error ) {
jQuery.readyException( error );
} );
return this;
};
jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Handle when the DOM is ready
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] );
}
} );
jQuery.ready.then = readyList.then;
// The ready event handler and self cleanup method
function completed() {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
jQuery.ready();
}
// Catch cases where $(document).ready() is called
// after the browser event has already occurred.
// Support: IE <=9 - 10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
} else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed );
}
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
len = elems.length,
bulk = key == null;
// Sets many values
if ( toType( key ) === "object" ) {
chainable = true;
for ( i in key ) {
access( elems, fn, i, key[ i ], true, emptyGet, raw );
}
// Sets one value
} else if ( value !== undefined ) {
chainable = true;
if ( !isFunction( value ) ) {
raw = true;
}
if ( bulk ) {
// Bulk operations run against the entire set
if ( raw ) {
fn.call( elems, value );
fn = null;
// ...except when executing function values
} else {
bulk = fn;
fn = function( elem, key, value ) {
return bulk.call( jQuery( elem ), value );
};
}
}
if ( fn ) {
for ( ; i < len; i++ ) {
fn(
elems[ i ], key, raw ?
value :
value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
}
}
}
if ( chainable ) {
return elems;
}
// Gets
if ( bulk ) {
return fn.call( elems );
}
return len ? fn( elems[ 0 ], key ) : emptyGet;
};
// Matches dashed string for camelizing
var rmsPrefix = /^-ms-/,
rdashAlpha = /-([a-z])/g;
// Used by camelCase as callback to replace()
function fcamelCase( all, letter ) {
return letter.toUpperCase();
}
// Convert dashed to camelCase; used by the css and data modules
// Support: IE <=9 - 11, Edge 12 - 15
// Microsoft forgot to hump their vendor prefix (#9572)
function camelCase( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
}
var acceptData = function( owner ) {
// Accepts only:
// - Node
// - Node.ELEMENT_NODE
// - Node.DOCUMENT_NODE
// - Object
// - Any
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
};
function Data() {
this.expando = jQuery.expando + Data.uid++;
}
Data.uid = 1;
Data.prototype = {
cache: function( owner ) {
// Check if the owner object already has a cache
var value = owner[ this.expando ];
// If not, create one
if ( !value ) {
value = {};
// We can accept data for non-element nodes in modern browsers,
// but we should not, see #8335.
// Always return an empty object.
if ( acceptData( owner ) ) {
// If it is a node unlikely to be stringify-ed or looped over
// use plain assignment
if ( owner.nodeType ) {
owner[ this.expando ] = value;
// Otherwise secure it in a non-enumerable property
// configurable must be true to allow the property to be
// deleted when data is removed
} else {
Object.defineProperty( owner, this.expando, {
value: value,
configurable: true
} );
}
}
}
return value;
},
set: function( owner, data, value ) {
var prop,
cache = this.cache( owner );
// Handle: [ owner, key, value ] args
// Always use camelCase key (gh-2257)
if ( typeof data === "string" ) {
cache[ camelCase( data ) ] = value;
// Handle: [ owner, { properties } ] args
} else {
// Copy the properties one-by-one to the cache object
for ( prop in data ) {
cache[ camelCase( prop ) ] = data[ prop ];
}
}
return cache;
},
get: function( owner, key ) {
return key === undefined ?
this.cache( owner ) :
// Always use camelCase key (gh-2257)
owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
},
access: function( owner, key, value ) {
// In cases where either:
//
// 1. No key was specified
// 2. A string key was specified, but no value provided
//
// Take the "read" path and allow the get method to determine
// which value to return, respectively either:
//
// 1. The entire cache object
// 2. The data stored at the key
//
if ( key === undefined ||
( ( key && typeof key === "string" ) && value === undefined ) ) {
return this.get( owner, key );
}
// When the key is not a string, or both a key and value
// are specified, set or extend (existing objects) with either:
//
// 1. An object of properties
// 2. A key and value
//
this.set( owner, key, value );
// Since the "set" path can have two possible entry points
// return the expected data based on which path was taken[*]
return value !== undefined ? value : key;
},
remove: function( owner, key ) {
var i,
cache = owner[ this.expando ];
if ( cache === undefined ) {
return;
}
if ( key !== undefined ) {
// Support array or space separated string of keys
if ( Array.isArray( key ) ) {
// If key is an array of keys...
// We always set camelCase keys, so remove that.
key = key.map( camelCase );
} else {
key = camelCase( key );
// If a key with the spaces exists, use it.
// Otherwise, create an array by matching non-whitespace
key = key in cache ?
[ key ] :
( key.match( rnothtmlwhite ) || [] );
}
i = key.length;
while ( i-- ) {
delete cache[ key[ i ] ];
}
}
// Remove the expando if there's no more data
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
// Support: Chrome <=35 - 45
// Webkit & Blink performance suffers when deleting properties
// from DOM nodes, so set to undefined instead
// https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
if ( owner.nodeType ) {
owner[ this.expando ] = undefined;
} else {
delete owner[ this.expando ];
}
}
},
hasData: function( owner ) {
var cache = owner[ this.expando ];
return cache !== undefined && !jQuery.isEmptyObject( cache );
}
};
var dataPriv = new Data();
var dataUser = new Data();
// Implementation Summary
//
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
// 2. Improve the module's maintainability by reducing the storage
// paths to a single mechanism.
// 3. Use the same single mechanism to support "private" and "user" data.
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /[A-Z]/g;
function getData( data ) {
if ( data === "true" ) {
return true;
}
if ( data === "false" ) {
return false;
}
if ( data === "null" ) {
return null;
}
// Only convert to a number if it doesn't change the string
if ( data === +data + "" ) {
return +data;
}
if ( rbrace.test( data ) ) {
return JSON.parse( data );
}
return data;
}
function dataAttr( elem, key, data ) {
var name;
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
data = elem.getAttribute( name );
if ( typeof data === "string" ) {
try {
data = getData( data );
} catch ( e ) {}
// Make sure we set the data so it isn't changed later
dataUser.set( elem, key, data );
} else {
data = undefined;
}
}
return data;
}
jQuery.extend( {
hasData: function( elem ) {
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
},
data: function( elem, name, data ) {
return dataUser.access( elem, name, data );
},
removeData: function( elem, name ) {
dataUser.remove( elem, name );
},
// TODO: Now that all calls to _data and _removeData have been replaced
// with direct calls to dataPriv methods, these can be deprecated.
_data: function( elem, name, data ) {
return dataPriv.access( elem, name, data );
},
_removeData: function( elem, name ) {
dataPriv.remove( elem, name );
}
} );
jQuery.fn.extend( {
data: function( key, value ) {
var i, name, data,
elem = this[ 0 ],
attrs = elem && elem.attributes;
// Gets all values
if ( key === undefined ) {
if ( this.length ) {
data = dataUser.get( elem );
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
i = attrs.length;
while ( i-- ) {
// Support: IE 11 only
// The attrs elements can be null (#14894)
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) {
name = camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] );
}
}
}
dataPriv.set( elem, "hasDataAttrs", true );
}
}
return data;
}
// Sets multiple values
if ( typeof key === "object" ) {
return this.each( function() {
dataUser.set( this, key );
} );
}
return access( this, function( value ) {
var data;
// The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the
// `value` parameter was not undefined. An empty jQuery object
// will result in `undefined` for elem = this[ 0 ] which will
// throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) {
// Attempt to get data from the cache
// The key will always be camelCased in Data
data = dataUser.get( elem, key );
if ( data !== undefined ) {
return data;
}
// Attempt to "discover" the data in
// HTML5 custom data-* attrs
data = dataAttr( elem, key );
if ( data !== undefined ) {
return data;
}
// We tried really hard, but the data doesn't exist.
return;
}
// Set the data...
this.each( function() {
// We always store the camelCased key
dataUser.set( this, key, value );
} );
}, null, value, arguments.length > 1, null, true );
},
removeData: function( key ) {
return this.each( function() {
dataUser.remove( this, key );
} );
}
} );
jQuery.extend( {
queue: function( elem, type, data ) {
var queue;
if ( elem ) {
type = ( type || "fx" ) + "queue";
queue = dataPriv.get( elem, type );
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !queue || Array.isArray( data ) ) {
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
} else {
queue.push( data );
}
}
return queue || [];
}
},
dequeue: function( elem, type ) {
type = type || "fx";
var queue = jQuery.queue( elem, type ),
startLength = queue.length,
fn = queue.shift(),
hooks = jQuery._queueHooks( elem, type ),
next = function() {
jQuery.dequeue( elem, type );
};
// If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) {
fn = queue.shift();
startLength--;
}
if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if ( type === "fx" ) {
queue.unshift( "inprogress" );
}
// Clear up the last queue stop function
delete hooks.stop;
fn.call( elem, next, hooks );
}
if ( !startLength && hooks ) {
hooks.empty.fire();
}
},
// Not public - generate a queueHooks object, or return the current one
_queueHooks: function( elem, type ) {
var key = type + "queueHooks";
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
empty: jQuery.Callbacks( "once memory" ).add( function() {
dataPriv.remove( elem, [ type + "queue", key ] );
} )
} );
}
} );
jQuery.fn.extend( {
queue: function( type, data ) {
var setter = 2;
if ( typeof type !== "string" ) {
data = type;
type = "fx";
setter--;
}
if ( arguments.length < setter ) {
return jQuery.queue( this[ 0 ], type );
}
return data === undefined ?
this :
this.each( function() {
var queue = jQuery.queue( this, type, data );
// Ensure a hooks for this queue
jQuery._queueHooks( this, type );
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
jQuery.dequeue( this, type );
}
} );
},
dequeue: function( type ) {
return this.each( function() {
jQuery.dequeue( this, type );
} );
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, obj ) {
var tmp,
count = 1,
defer = jQuery.Deferred(),
elements = this,
i = this.length,
resolve = function() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
}
};
if ( typeof type !== "string" ) {
obj = type;
type = undefined;
}
type = type || "fx";
while ( i-- ) {
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
if ( tmp && tmp.empty ) {
count++;
tmp.empty.add( resolve );
}
}
resolve();
return defer.promise( obj );
}
} );
var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
var documentElement = document.documentElement;
var isAttached = function( elem ) {
return jQuery.contains( elem.ownerDocument, elem );
},
composed = { composed: true };
// Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
// Check attachment across shadow DOM boundaries when possible (gh-3504)
// Support: iOS 10.0-10.2 only
// Early iOS 10 versions support `attachShadow` but not `getRootNode`,
// leading to errors. We need to check for `getRootNode`.
if ( documentElement.getRootNode ) {
isAttached = function( elem ) {
return jQuery.contains( elem.ownerDocument, elem ) ||
elem.getRootNode( composed ) === elem.ownerDocument;
};
}
var isHiddenWithinTree = function( elem, el ) {
// isHiddenWithinTree might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
// Inline style trumps all
return elem.style.display === "none" ||
elem.style.display === "" &&
// Otherwise, check computed style
// Support: Firefox <=43 - 45
// Disconnected elements can have computed display: none, so first confirm that elem is
// in the document.
isAttached( elem ) &&
jQuery.css( elem, "display" ) === "none";
};
var swap = function( elem, options, callback, args ) {
var ret, name,
old = {};
// Remember the old values, and insert the new ones
for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
ret = callback.apply( elem, args || [] );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
return ret;
};
function adjustCSS( elem, prop, valueParts, tween ) {
var adjusted, scale,
maxIterations = 20,
currentValue = tween ?
function() {
return tween.cur();
} :
function() {
return jQuery.css( elem, prop, "" );
},
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = elem.nodeType &&
( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Support: Firefox <=54
// Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
initial = initial / 2;
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
// Iteratively approximate from a nonzero starting point
initialInUnit = +initial || 1;
while ( maxIterations-- ) {
// Evaluate and update our best guess (doubling guesses that zero out).
// Finish if the scale equals or crosses 1 (making the old*new product non-positive).
jQuery.style( elem, prop, initialInUnit + unit );
if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
maxIterations = 0;
}
initialInUnit = initialInUnit / scale;
}
initialInUnit = initialInUnit * 2;
jQuery.style( elem, prop, initialInUnit + unit );
// Make sure we update the tween properties later on
valueParts = valueParts || [];
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+valueParts[ 2 ];
if ( tween ) {
tween.unit = unit;
tween.start = initialInUnit;
tween.end = adjusted;
}
}
return adjusted;
}
var defaultDisplayMap = {};
function getDefaultDisplay( elem ) {
var temp,
doc = elem.ownerDocument,
nodeName = elem.nodeName,
display = defaultDisplayMap[ nodeName ];
if ( display ) {
return display;
}
temp = doc.body.appendChild( doc.createElement( nodeName ) );
display = jQuery.css( temp, "display" );
temp.parentNode.removeChild( temp );
if ( display === "none" ) {
display = "block";
}
defaultDisplayMap[ nodeName ] = display;
return display;
}
function showHide( elements, show ) {
var display, elem,
values = [],
index = 0,
length = elements.length;
// Determine new display value for elements that need to change
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
display = elem.style.display;
if ( show ) {
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
// check is required in this first loop unless we have a nonempty display value (either
// inline or about-to-be-restored)
if ( display === "none" ) {
values[ index ] = dataPriv.get( elem, "display" ) || null;
if ( !values[ index ] ) {
elem.style.display = "";
}
}
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
values[ index ] = getDefaultDisplay( elem );
}
} else {
if ( display !== "none" ) {
values[ index ] = "none";
// Remember what we're overwriting
dataPriv.set( elem, "display", display );
}
}
}
// Set the display of the elements in a second loop to avoid constant reflow
for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ];
}
}
return elements;
}
jQuery.fn.extend( {
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHiddenWithinTree( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
}
} );
var rcheckableType = ( /^(?:checkbox|radio)$/i );
var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
// We have to close these tags to support XHTML (#13200)
var wrapMap = {
// Support: IE <=9 only
option: [ 1, "<select multiple='multiple'>", "</select>" ],
// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
// Support: IE <=9 only
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
function getAll( context, tag ) {
// Support: IE <=9 - 11 only
// Use typeof to avoid zero-argument method invocation on host objects (#15151)
var ret;
if ( typeof context.getElementsByTagName !== "undefined" ) {
ret = context.getElementsByTagName( tag || "*" );
} else if ( typeof context.querySelectorAll !== "undefined" ) {
ret = context.querySelectorAll( tag || "*" );
} else {
ret = [];
}
if ( tag === undefined || tag && nodeName( context, tag ) ) {
return jQuery.merge( [ context ], ret );
}
return ret;
}
// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
dataPriv.set(
elems[ i ],
"globalEval",
!refElements || dataPriv.get( refElements[ i ], "globalEval" )
);
}
}
var rhtml = /<|&#?\w+;/;
function buildFragment( elems, context, scripts, selection, ignored ) {
var elem, tmp, tag, wrap, attached, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( toType( elem ) === "object" ) {
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (#12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( ( elem = nodes[ i++ ] ) ) {
// Skip elements already in the context collection (trac-4087)
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
if ( ignored ) {
ignored.push( elem );
}
continue;
}
attached = isAttached( elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( attached ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( ( elem = tmp[ j++ ] ) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
}
( function() {
var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" );
// Support: Android 4.0 - 4.3 only
// Check state lost if the name is set (#11217)
// Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "radio" );
input.setAttribute( "checked", "checked" );
input.setAttribute( "name", "t" );
div.appendChild( input );
// Support: Android <=4.1 only
// Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE <=11 only
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
} )();
var
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
// Support: IE <=9 - 11+
// focus() and blur() are asynchronous, except when they are no-op.
// So expect focus to be synchronous when the element is already active,
// and blur to be synchronous when the element is not already active.
// (focus and blur are always synchronous in other supported browsers,
// this just defines when we can count on it).
function expectSync( elem, type ) {
return ( elem === safeActiveElement() ) === ( type === "focus" );
}
// Support: IE <=9 only
// Accessing document.activeElement can throw unexpectedly
// https://bugs.jquery.com/ticket/13393
function safeActiveElement() {
try {
return document.activeElement;
} catch ( err ) { }
}
function on( elem, types, selector, data, fn, one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
on( elem, type, selector, data, types[ type ], one );
}
return elem;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return elem;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
} );
}
/*
* Helper functions for managing events -- not part of the public interface.
* Props to Dean Edwards' addEvent library for many of the ideas.
*/
jQuery.event = {
global: {},
add: function( elem, types, handler, data, selector ) {
var handleObjIn, eventHandle, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData = dataPriv.get( elem );
// Don't attach events to noData or text/comment nodes (but allow plain objects)
if ( !elemData ) {
return;
}
// Caller can pass in an object of custom data in lieu of the handler
if ( handler.handler ) {
handleObjIn = handler;
handler = handleObjIn.handler;
selector = handleObjIn.selector;
}
// Ensure that invalid selectors throw exceptions at attach time
// Evaluate against documentElement in case elem is a non-element node (e.g., document)
if ( selector ) {
jQuery.find.matchesSelector( documentElement, selector );
}
// Make sure that the handler has a unique ID, used to find/remove it later
if ( !handler.guid ) {
handler.guid = jQuery.guid++;
}
// Init the element's event structure and main handler, if this is the first
if ( !( events = elemData.events ) ) {
events = elemData.events = {};
}
if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
};
}
// Handle multiple events separated by a space
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// There *must* be a type, no attaching namespace-only handlers
if ( !type ) {
continue;
}
// If event changes its type, use the special event handlers for the changed type
special = jQuery.event.special[ type ] || {};
// If selector defined, determine special event api type, otherwise given type
type = ( selector ? special.delegateType : special.bindType ) || type;
// Update special based on newly reset type
special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers
handleObj = jQuery.extend( {
type: type,
origType: origType,
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join( "." )
}, handleObjIn );
// Init the event handler queue if we're the first
if ( !( handlers = events[ type ] ) ) {
handlers = events[ type ] = [];
handlers.delegateCount = 0;
// Only use addEventListener if the special events handler returns false
if ( !special.setup ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle );
}
}
}
if ( special.add ) {
special.add.call( elem, handleObj );
if ( !handleObj.handler.guid ) {
handleObj.handler.guid = handler.guid;
}
}
// Add to the element's handler list, delegates in front
if ( selector ) {
handlers.splice( handlers.delegateCount++, 0, handleObj );
} else {
handlers.push( handleObj );
}
// Keep track of which events have ever been used, for event optimization
jQuery.event.global[ type ] = true;
}
},
// Detach an event or set of events from an element
remove: function( elem, types, handler, selector, mappedTypes ) {
var j, origCount, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
if ( !elemData || !( events = elemData.events ) ) {
return;
}
// Once for each type.namespace in types; type may be omitted
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element
if ( !type ) {
for ( type in events ) {
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
}
continue;
}
special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || [];
tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
// Remove matching events
origCount = j = handlers.length;
while ( j-- ) {
handleObj = handlers[ j ];
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
handlers.splice( j, 1 );
if ( handleObj.selector ) {
handlers.delegateCount--;
}
if ( special.remove ) {
special.remove.call( elem, handleObj );
}
}
}
// Remove generic event handler if we removed something and no more handlers exist
// (avoids potential for endless recursion during removal of special event handlers)
if ( origCount && !handlers.length ) {
if ( !special.teardown ||
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
jQuery.removeEvent( elem, type, elemData.handle );
}
delete events[ type ];
}
}
// Remove data and the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) {
dataPriv.remove( elem, "handle events" );
}
},
dispatch: function( nativeEvent ) {
// Make a writable jQuery.Event from the native event object
var event = jQuery.event.fix( nativeEvent );
var i, j, ret, matched, handleObj, handlerQueue,
args = new Array( arguments.length ),
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[ 0 ] = event;
for ( i = 1; i < arguments.length; i++ ) {
args[ i ] = arguments[ i ];
}
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
return;
}
// Determine handlers
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
// If the event is namespaced, then each handler is only invoked if it is
// specially universal or its namespaces are a superset of the event's.
if ( !event.rnamespace || handleObj.namespace === false ||
event.rnamespace.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) {
if ( ( event.result = ret ) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
}
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
},
handlers: function( event, handlers ) {
var i, handleObj, sel, matchedHandlers, matchedSelectors,
handlerQueue = [],
delegateCount = handlers.delegateCount,
cur = event.target;
// Find delegate handlers
if ( delegateCount &&
// Support: IE <=9
// Black-hole SVG <use> instance trees (trac-13180)
cur.nodeType &&
// Support: Firefox <=42
// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
// Support: IE 11 only
// ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
!( event.type === "click" && event.button >= 1 ) ) {
for ( ; cur !== this; cur = cur.parentNode || this ) {
// Don't check non-elements (#13208)
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
matchedHandlers = [];
matchedSelectors = {};
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
// Don't conflict with Object.prototype properties (#13203)
sel = handleObj.selector + " ";
if ( matchedSelectors[ sel ] === undefined ) {
matchedSelectors[ sel ] = handleObj.needsContext ?
jQuery( sel, this ).index( cur ) > -1 :
jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( matchedSelectors[ sel ] ) {
matchedHandlers.push( handleObj );
}
}
if ( matchedHandlers.length ) {
handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
}
}
}
}
// Add the remaining (directly-bound) handlers
cur = this;
if ( delegateCount < handlers.length ) {
handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
}
return handlerQueue;
},
addProp: function( name, hook ) {
Object.defineProperty( jQuery.Event.prototype, name, {
enumerable: true,
configurable: true,
get: isFunction( hook ) ?
function() {
if ( this.originalEvent ) {
return hook( this.originalEvent );
}
} :
function() {
if ( this.originalEvent ) {
return this.originalEvent[ name ];
}
},
set: function( value ) {
Object.defineProperty( this, name, {
enumerable: true,
configurable: true,
writable: true,
value: value
} );
}
} );
},
fix: function( originalEvent ) {
return originalEvent[ jQuery.expando ] ?
originalEvent :
new jQuery.Event( originalEvent );
},
special: {
load: {
// Prevent triggered image.load events from bubbling to window.load
noBubble: true
},
click: {
// Utilize native event to ensure correct state for checkable inputs
setup: function( data ) {
// For mutual compressibility with _default, replace `this` access with a local var.
// `|| data` is dead code meant only to preserve the variable through minification.
var el = this || data;
// Claim the first handler
if ( rcheckableType.test( el.type ) &&
el.click && nodeName( el, "input" ) ) {
// dataPriv.set( el, "click", ... )
leverageNative( el, "click", returnTrue );
}
// Return false to allow normal processing in the caller
return false;
},
trigger: function( data ) {
// For mutual compressibility with _default, replace `this` access with a local var.
// `|| data` is dead code meant only to preserve the variable through minification.
var el = this || data;
// Force setup before triggering a click
if ( rcheckableType.test( el.type ) &&
el.click && nodeName( el, "input" ) ) {
leverageNative( el, "click" );
}
// Return non-false to allow normal event-path propagation
return true;
},
// For cross-browser consistency, suppress native .click() on links
// Also prevent it if we're currently inside a leveraged native-event stack
_default: function( event ) {
var target = event.target;
return rcheckableType.test( target.type ) &&
target.click && nodeName( target, "input" ) &&
dataPriv.get( target, "click" ) ||
nodeName( target, "a" );
}
},
beforeunload: {
postDispatch: function( event ) {
// Support: Firefox 20+
// Firefox doesn't alert if the returnValue field is not set.
if ( event.result !== undefined && event.originalEvent ) {
event.originalEvent.returnValue = event.result;
}
}
}
}
};
// Ensure the presence of an event listener that handles manually-triggered
// synthetic events by interrupting progress until reinvoked in response to
// *native* events that it fires directly, ensuring that state changes have
// already occurred before other listeners are invoked.
function leverageNative( el, type, expectSync ) {
// Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
if ( !expectSync ) {
if ( dataPriv.get( el, type ) === undefined ) {
jQuery.event.add( el, type, returnTrue );
}
return;
}
// Register the controller as a special universal handler for all event namespaces
dataPriv.set( el, type, false );
jQuery.event.add( el, type, {
namespace: false,
handler: function( event ) {
var notAsync, result,
saved = dataPriv.get( this, type );
if ( ( event.isTrigger & 1 ) && this[ type ] ) {
// Interrupt processing of the outer synthetic .trigger()ed event
// Saved data should be false in such cases, but might be a leftover capture object
// from an async native handler (gh-4350)
if ( !saved.length ) {
// Store arguments for use when handling the inner native event
// There will always be at least one argument (an event object), so this array
// will not be confused with a leftover capture object.
saved = slice.call( arguments );
dataPriv.set( this, type, saved );
// Trigger the native event and capture its result
// Support: IE <=9 - 11+
// focus() and blur() are asynchronous
notAsync = expectSync( this, type );
this[ type ]();
result = dataPriv.get( this, type );
if ( saved !== result || notAsync ) {
dataPriv.set( this, type, false );
} else {
result = {};
}
if ( saved !== result ) {
// Cancel the outer synthetic event
event.stopImmediatePropagation();
event.preventDefault();
return result.value;
}
// If this is an inner synthetic event for an event with a bubbling surrogate
// (focus or blur), assume that the surrogate already propagated from triggering the
// native event and prevent that from happening again here.
// This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
// bubbling surrogate propagates *after* the non-bubbling base), but that seems
// less bad than duplication.
} else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
event.stopPropagation();
}
// If this is a native event triggered above, everything is now in order
// Fire an inner synthetic event with the original arguments
} else if ( saved.length ) {
// ...and capture the result
dataPriv.set( this, type, {
value: jQuery.event.trigger(
// Support: IE <=9 - 11+
// Extend with the prototype to reset the above stopImmediatePropagation()
jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
saved.slice( 1 ),
this
)
} );
// Abort handling of the native event
event.stopImmediatePropagation();
}
}
} );
}
jQuery.removeEvent = function( elem, type, handle ) {
// This "if" is needed for plain objects
if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle );
}
};
jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword
if ( !( this instanceof jQuery.Event ) ) {
return new jQuery.Event( src, props );
}
// Event object
if ( src && src.type ) {
this.originalEvent = src;
this.type = src.type;
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented ||
src.defaultPrevented === undefined &&
// Support: Android <=2.3 only
src.returnValue === false ?
returnTrue :
returnFalse;
// Create target properties
// Support: Safari <=6 - 7 only
// Target should not be a text node (#504, #13143)
this.target = ( src.target && src.target.nodeType === 3 ) ?
src.target.parentNode :
src.target;
this.currentTarget = src.currentTarget;
this.relatedTarget = src.relatedTarget;
// Event type
} else {
this.type = src;
}
// Put explicitly provided properties onto the event object
if ( props ) {
jQuery.extend( this, props );
}
// Create a timestamp if incoming event doesn't have one
this.timeStamp = src && src.timeStamp || Date.now();
// Mark it as fixed
this[ jQuery.expando ] = true;
};
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = {
constructor: jQuery.Event,
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
isSimulated: false,
preventDefault: function() {
var e = this.originalEvent;
this.isDefaultPrevented = returnTrue;
if ( e && !this.isSimulated ) {
e.preventDefault();
}
},
stopPropagation: function() {
var e = this.originalEvent;
this.isPropagationStopped = returnTrue;
if ( e && !this.isSimulated ) {
e.stopPropagation();
}
},
stopImmediatePropagation: function() {
var e = this.originalEvent;
this.isImmediatePropagationStopped = returnTrue;
if ( e && !this.isSimulated ) {
e.stopImmediatePropagation();
}
this.stopPropagation();
}
};
// Includes all common event props including KeyEvent and MouseEvent specific props
jQuery.each( {
altKey: true,
bubbles: true,
cancelable: true,
changedTouches: true,
ctrlKey: true,
detail: true,
eventPhase: true,
metaKey: true,
pageX: true,
pageY: true,
shiftKey: true,
view: true,
"char": true,
code: true,
charCode: true,
key: true,
keyCode: true,
button: true,
buttons: true,
clientX: true,
clientY: true,
offsetX: true,
offsetY: true,
pointerId: true,
pointerType: true,
screenX: true,
screenY: true,
targetTouches: true,
toElement: true,
touches: true,
which: function( event ) {
var button = event.button;
// Add which for key events
if ( event.which == null && rkeyEvent.test( event.type ) ) {
return event.charCode != null ? event.charCode : event.keyCode;
}
// Add which for click: 1 === left; 2 === middle; 3 === right
if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
if ( button & 1 ) {
return 1;
}
if ( button & 2 ) {
return 3;
}
if ( button & 4 ) {
return 2;
}
return 0;
}
return event.which;
}
}, jQuery.event.addProp );
jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
jQuery.event.special[ type ] = {
// Utilize native event if possible so blur/focus sequence is correct
setup: function() {
// Claim the first handler
// dataPriv.set( this, "focus", ... )
// dataPriv.set( this, "blur", ... )
leverageNative( this, type, expectSync );
// Return false to allow normal processing in the caller
return false;
},
trigger: function() {
// Force setup before trigger
leverageNative( this, type );
// Return non-false to allow normal event-path propagation
return true;
},
delegateType: delegateType
};
} );
// Create mouseenter/leave events using mouseover/out and event-time checks
// so that event delegation works in jQuery.
// Do the same for pointerenter/pointerleave and pointerover/pointerout
//
// Support: Safari 7 only
// Safari sends mouseenter too often; see:
// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well).
jQuery.each( {
mouseenter: "mouseover",
mouseleave: "mouseout",
pointerenter: "pointerover",
pointerleave: "pointerout"
}, function( orig, fix ) {
jQuery.event.special[ orig ] = {
delegateType: fix,
bindType: fix,
handle: function( event ) {
var ret,
target = this,
related = event.relatedTarget,
handleObj = event.handleObj;
// For mouseenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments );
event.type = fix;
}
return ret;
}
};
} );
jQuery.fn.extend( {
on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn );
},
one: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn, 1 );
},
off: function( types, selector, fn ) {
var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event
handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
handleObj.namespace ?
handleObj.origType + "." + handleObj.namespace :
handleObj.origType,
handleObj.selector,
handleObj.handler
);
return this;
}
if ( typeof types === "object" ) {
// ( types-object [, selector] )
for ( type in types ) {
this.off( type, selector, types[ type ] );
}
return this;
}
if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] )
fn = selector;
selector = undefined;
}
if ( fn === false ) {
fn = returnFalse;
}
return this.each( function() {
jQuery.event.remove( this, types, fn, selector );
} );
}
} );
var
/* eslint-disable max-len */
// See https://github.com/eslint/eslint/issues/3229
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
/* eslint-enable */
// Support: IE <=10 - 11, Edge 12 - 13 only
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
rnoInnerhtml = /<script|<style|<link/i,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
// Prefer a tbody over its parent table for containing new rows
function manipulationTarget( elem, content ) {
if ( nodeName( elem, "table" ) &&
nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
}
return elem;
}
// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
return elem;
}
function restoreScript( elem ) {
if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
elem.type = elem.type.slice( 5 );
} else {
elem.removeAttribute( "type" );
}
return elem;
}
function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
if ( dest.nodeType !== 1 ) {
return;
}
// 1. Copy private data: events, handlers, etc.
if ( dataPriv.hasData( src ) ) {
pdataOld = dataPriv.access( src );
pdataCur = dataPriv.set( dest, pdataOld );
events = pdataOld.events;
if ( events ) {
delete pdataCur.handle;
pdataCur.events = {};
for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}
}
// 2. Copy user data
if ( dataUser.hasData( src ) ) {
udataOld = dataUser.access( src );
udataCur = jQuery.extend( {}, udataOld );
dataUser.set( dest, udataCur );
}
}
// Fix IE bugs, see support tests
function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase();
// Fails to persist the checked state of a cloned checkbox or radio button.
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
dest.checked = src.checked;
// Fails to return the selected option to the default selected state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
}
function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[ 0 ],
valueIsFunction = isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( valueIsFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return collection.each( function( index ) {
var self = collection.eq( index );
if ( valueIsFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
domManip( self, args, callback, ignored );
} );
}
if ( l ) {
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
// Require either new content or an interest in ignored elements to invoke the callback
if ( first || ignored ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item
// instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!dataPriv.access( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) {
if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl && !node.noModule ) {
jQuery._evalUrl( node.src, {
nonce: node.nonce || node.getAttribute( "nonce" )
} );
}
} else {
DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
}
}
}
}
}
}
return collection;
}
function remove( elem, selector, keepData ) {
var node,
nodes = selector ? jQuery.filter( selector, elem ) : elem,
i = 0;
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) );
}
if ( node.parentNode ) {
if ( keepData && isAttached( node ) ) {
setGlobalEval( getAll( node, "script" ) );
}
node.parentNode.removeChild( node );
}
}
return elem;
}
jQuery.extend( {
htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
},
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var i, l, srcElements, destElements,
clone = elem.cloneNode( true ),
inPage = isAttached( elem );
// Fix IE cloning issues
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone );
srcElements = getAll( elem );
for ( i = 0, l = srcElements.length; i < l; i++ ) {
fixInput( srcElements[ i ], destElements[ i ] );
}
}
// Copy the events from the original to the clone
if ( dataAndEvents ) {
if ( deepDataAndEvents ) {
srcElements = srcElements || getAll( elem );
destElements = destElements || getAll( clone );
for ( i = 0, l = srcElements.length; i < l; i++ ) {
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
}
} else {
cloneCopyEvent( elem, clone );
}
}
// Preserve script evaluation history
destElements = getAll( clone, "script" );
if ( destElements.length > 0 ) {
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
}
// Return the cloned set
return clone;
},
cleanData: function( elems ) {
var data, elem, type,
special = jQuery.event.special,
i = 0;
for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
if ( acceptData( elem ) ) {
if ( ( data = elem[ dataPriv.expando ] ) ) {
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
}
// Support: Chrome <=35 - 45+
// Assign undefined instead of using delete, see Data#remove
elem[ dataPriv.expando ] = undefined;
}
if ( elem[ dataUser.expando ] ) {
// Support: Chrome <=35 - 45+
// Assign undefined instead of using delete, see Data#remove
elem[ dataUser.expando ] = undefined;
}
}
}
}
} );
jQuery.fn.extend( {
detach: function( selector ) {
return remove( this, selector, true );
},
remove: function( selector ) {
return remove( this, selector );
},
text: function( value ) {
return access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
this.empty().each( function() {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
this.textContent = value;
}
} );
}, null, value, arguments.length );
},
append: function() {
return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
} );
},
prepend: function() {
return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild );
}
} );
},
before: function() {
return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
} );
},
after: function() {
return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling );
}
} );
},
empty: function() {
var elem,
i = 0;
for ( ; ( elem = this[ i ] ) != null; i++ ) {
if ( elem.nodeType === 1 ) {
// Prevent memory leaks
jQuery.cleanData( getAll( elem, false ) );
// Remove any remaining nodes
elem.textContent = "";
}
}
return this;
},
clone: function( dataAndEvents, deepDataAndEvents ) {
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function() {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
} );
},
html: function( value ) {
return access( this, function( value ) {
var elem = this[ 0 ] || {},
i = 0,
l = this.length;
if ( value === undefined && elem.nodeType === 1 ) {
return elem.innerHTML;
}
// See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
value = jQuery.htmlPrefilter( value );
try {
for ( ; i < l; i++ ) {
elem = this[ i ] || {};
// Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value;
}
}
elem = 0;
// If using innerHTML throws an exception, use the fallback method
} catch ( e ) {}
}
if ( elem ) {
this.empty().append( value );
}
}, null, value, arguments.length );
},
replaceWith: function() {
var ignored = [];
// Make the changes, replacing each non-ignored context element with the new content
return domManip( this, arguments, function( elem ) {
var parent = this.parentNode;
if ( jQuery.inArray( this, ignored ) < 0 ) {
jQuery.cleanData( getAll( this ) );
if ( parent ) {
parent.replaceChild( elem, this );
}
}
// Force callback invocation
}, ignored );
}
} );
jQuery.each( {
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var elems,
ret = [],
insert = jQuery( selector ),
last = insert.length - 1,
i = 0;
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems );
// Support: Android <=4.0 only, PhantomJS 1 only
// .get() because push.apply(_, arraylike) throws on ancient WebKit
push.apply( ret, elems.get() );
}
return this.pushStack( ret );
};
} );
var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
var getStyles = function( elem ) {
// Support: IE <=11 only, Firefox <=30 (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
var view = elem.ownerDocument.defaultView;
if ( !view || !view.opener ) {
view = window;
}
return view.getComputedStyle( elem );
};
var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
( function() {
// Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation.
function computeStyleTests() {
// This is a singleton, we need to execute it only once
if ( !div ) {
return;
}
container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
"margin-top:1px;padding:0;border:0";
div.style.cssText =
"position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
"margin:auto;border:1px;padding:1px;" +
"width:60%;top:1%";
documentElement.appendChild( container ).appendChild( div );
var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%";
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
// Some styles come back with percentage values, even though they shouldn't
div.style.right = "60%";
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
// Support: IE 9 - 11 only
// Detect misreporting of content dimensions for box-sizing:border-box elements
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
// Support: IE 9 only
// Detect overflow:scroll screwiness (gh-3699)
// Support: Chrome <=64
// Don't get tricked when zoom affects offsetWidth (gh-4029)
div.style.position = "absolute";
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
documentElement.removeChild( container );
// Nullify the div so it wouldn't be stored in the memory and
// it will also be a sign that checks already performed
div = null;
}
function roundPixelMeasures( measure ) {
return Math.round( parseFloat( measure ) );
}
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
reliableMarginLeftVal,
container = document.createElement( "div" ),
div = document.createElement( "div" );
// Finish early in limited (non-browser) environments
if ( !div.style ) {
return;
}
// Support: IE <=9 - 11 only
// Style of cloned element affects source element cloned (#8908)
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
jQuery.extend( support, {
boxSizingReliable: function() {
computeStyleTests();
return boxSizingReliableVal;
},
pixelBoxStyles: function() {
computeStyleTests();
return pixelBoxStylesVal;
},
pixelPosition: function() {
computeStyleTests();
return pixelPositionVal;
},
reliableMarginLeft: function() {
computeStyleTests();
return reliableMarginLeftVal;
},
scrollboxSize: function() {
computeStyleTests();
return scrollboxSizeVal;
}
} );
} )();
function curCSS( elem, name, computed ) {
var width, minWidth, maxWidth, ret,
// Support: Firefox 51+
// Retrieving style before computed somehow
// fixes an issue with getting wrong values
// on detached elements
style = elem.style;
computed = computed || getStyles( elem );
// getPropertyValue is needed for:
// .css('filter') (IE 9 only, #12537)
// .css('--customProperty) (#3144)
if ( computed ) {
ret = computed.getPropertyValue( name ) || computed[ name ];
if ( ret === "" && !isAttached( elem ) ) {
ret = jQuery.style( elem, name );
}
// A tribute to the "awesome hack by Dean Edwards"
// Android Browser returns percentage for some values,
// but width seems to be reliably pixels.
// This is against the CSSOM draft spec:
// https://drafts.csswg.org/cssom/#resolved-values
if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
// Remember the original values
width = style.width;
minWidth = style.minWidth;
maxWidth = style.maxWidth;
// Put in the new values to get a computed value out
style.minWidth = style.maxWidth = style.width = ret;
ret = computed.width;
// Revert the changed values
style.width = width;
style.minWidth = minWidth;
style.maxWidth = maxWidth;
}
}
return ret !== undefined ?
// Support: IE <=9 - 11 only
// IE returns zIndex value as an integer.
ret + "" :
ret;
}
function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed.
return {
get: function() {
if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due
// to missing dependency), remove it.
delete this.get;
return;
}
// Hook needed; redefine it so that the support test is not executed again.
return ( this.get = hookFn ).apply( this, arguments );
}
};
}
var cssPrefixes = [ "Webkit", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style,
vendorProps = {};
// Return a vendor-prefixed property or undefined
function vendorPropName( name ) {
// Check for vendor prefixed names
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in emptyStyle ) {
return name;
}
}
}
// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
function finalPropName( name ) {
var final = jQuery.cssProps[ name ] || vendorProps[ name ];
if ( final ) {
return final;
}
if ( name in emptyStyle ) {
return name;
}
return vendorProps[ name ] = vendorPropName( name ) || name;
}
var
// Swappable if display is none or starts with table
// except "table", "table-cell", or "table-caption"
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rcustomProp = /^--/,
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = {
letterSpacing: "0",
fontWeight: "400"
};
function setPositiveNumber( elem, value, subtract ) {
// Any relative (+/-) values have already been
// normalized at this point
var matches = rcssNum.exec( value );
return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
value;
}
function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
var i = dimension === "width" ? 1 : 0,
extra = 0,
delta = 0;
// Adjustment may not be necessary
if ( box === ( isBorderBox ? "border" : "content" ) ) {
return 0;
}
for ( ; i < 4; i += 2 ) {
// Both box models exclude margin
if ( box === "margin" ) {
delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
}
// If we get here with a content-box, we're seeking "padding" or "border" or "margin"
if ( !isBorderBox ) {
// Add padding
delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// For "border" or "margin", add border
if ( box !== "padding" ) {
delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
// But still keep track of it otherwise
} else {
extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
// If we get here with a border-box (content + padding + border), we're seeking "content" or
// "padding" or "margin"
} else {
// For "content", subtract padding
if ( box === "content" ) {
delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
}
// For "content" or "padding", subtract border
if ( box !== "margin" ) {
delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
}
}
// Account for positive content-box scroll gutter when requested by providing computedVal
if ( !isBorderBox && computedVal >= 0 ) {
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
// Assuming integer scroll gutter, subtract the rest and round down
delta += Math.max( 0, Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
computedVal -
delta -
extra -
0.5
// If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
// Use an explicit zero to avoid NaN (gh-3964)
) ) || 0;
}
return delta;
}
function getWidthOrHeight( elem, dimension, extra ) {
// Start with computed style
var styles = getStyles( elem ),
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
// Fake content-box until we know it's needed to know the true value.
boxSizingNeeded = !support.boxSizingReliable() || extra,
isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
valueIsBorderBox = isBorderBox,
val = curCSS( elem, dimension, styles ),
offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
// Support: Firefox <=54
// Return a confounding non-pixel value or feign ignorance, as appropriate.
if ( rnumnonpx.test( val ) ) {
if ( !extra ) {
return val;
}
val = "auto";
}
// Fall back to offsetWidth/offsetHeight when value is "auto"
// This happens for inline elements with no explicit setting (gh-3571)
// Support: Android <=4.1 - 4.3 only
// Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
// Support: IE 9-11 only
// Also use offsetWidth/offsetHeight for when box sizing is unreliable
// We use getClientRects() to check for hidden/disconnected.
// In those cases, the computed value can be trusted to be border-box
if ( ( !support.boxSizingReliable() && isBorderBox ||
val === "auto" ||
!parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
elem.getClientRects().length ) {
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Where available, offsetWidth/offsetHeight approximate border box dimensions.
// Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
// retrieved value as a content box dimension.
valueIsBorderBox = offsetProp in elem;
if ( valueIsBorderBox ) {
val = elem[ offsetProp ];
}
}
// Normalize "" and auto
val = parseFloat( val ) || 0;
// Adjust for the element's box model
return ( val +
boxModelAdjustment(
elem,
dimension,
extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox,
styles,
// Provide the current computed size to request scroll gutter calculation (gh-3589)
val
)
) + "px";
}
jQuery.extend( {
// Add in style property hooks for overriding the default
// behavior of getting and setting a style property
cssHooks: {
opacity: {
get: function( elem, computed ) {
if ( computed ) {
// We should always get a number back from opacity
var ret = curCSS( elem, "opacity" );
return ret === "" ? "1" : ret;
}
}
}
},
// Don't automatically add "px" to these possibly-unitless properties
cssNumber: {
"animationIterationCount": true,
"columnCount": true,
"fillOpacity": true,
"flexGrow": true,
"flexShrink": true,
"fontWeight": true,
"gridArea": true,
"gridColumn": true,
"gridColumnEnd": true,
"gridColumnStart": true,
"gridRow": true,
"gridRowEnd": true,
"gridRowStart": true,
"lineHeight": true,
"opacity": true,
"order": true,
"orphans": true,
"widows": true,
"zIndex": true,
"zoom": true
},
// Add in properties whose names you wish to fix before
// setting or getting the value
cssProps: {},
// Get and set the style property on a DOM Node
style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return;
}
// Make sure that we're working with the right name
var ret, type, hooks,
origName = camelCase( name ),
isCustomProp = rcustomProp.test( name ),
style = elem.style;
// Make sure that we're working with the right name. We don't
// want to query the value if it is a CSS custom property
// since they are user-defined.
if ( !isCustomProp ) {
name = finalPropName( origName );
}
// Gets hook for the prefixed version, then unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// Check if we're setting a value
if ( value !== undefined ) {
type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345)
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = adjustCSS( elem, name, ret );
// Fixes bug #9237
type = "number";
}
// Make sure that null and NaN values aren't set (#7116)
if ( value == null || value !== value ) {
return;
}
// If a number was passed in, add the unit (except for certain CSS properties)
// The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
// "px" to a few hardcoded values.
if ( type === "number" && !isCustomProp ) {
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
}
// background-* props affect original clone's values
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit";
}
// If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !( "set" in hooks ) ||
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
if ( isCustomProp ) {
style.setProperty( name, value );
} else {
style[ name ] = value;
}
}
} else {
// If a hook was provided get the non-computed value from there
if ( hooks && "get" in hooks &&
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret;
}
// Otherwise just get the value from the style object
return style[ name ];
}
},
css: function( elem, name, extra, styles ) {
var val, num, hooks,
origName = camelCase( name ),
isCustomProp = rcustomProp.test( name );
// Make sure that we're working with the right name. We don't
// want to modify the value if it is a CSS custom property
// since they are user-defined.
if ( !isCustomProp ) {
name = finalPropName( origName );
}
// Try prefixed name followed by the unprefixed name
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// If a hook was provided get the computed value from there
if ( hooks && "get" in hooks ) {
val = hooks.get( elem, true, extra );
}
// Otherwise, if a way to get the computed value exists, use that
if ( val === undefined ) {
val = curCSS( elem, name, styles );
}
// Convert "normal" to computed value
if ( val === "normal" && name in cssNormalTransform ) {
val = cssNormalTransform[ name ];
}
// Make numeric if forced or a qualifier was provided and val looks numeric
if ( extra === "" || extra ) {
num = parseFloat( val );
return extra === true || isFinite( num ) ? num || 0 : val;
}
return val;
}
} );
jQuery.each( [ "height", "width" ], function( i, dimension ) {
jQuery.cssHooks[ dimension ] = {
get: function( elem, computed, extra ) {
if ( computed ) {
// Certain elements can have dimension info if we invisibly show them
// but it must have a current display style that would benefit
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
// Support: Safari 8+
// Table columns in Safari have non-zero offsetWidth & zero
// getBoundingClientRect().width unless display is changed.
// Support: IE <=11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
swap( elem, cssShow, function() {
return getWidthOrHeight( elem, dimension, extra );
} ) :
getWidthOrHeight( elem, dimension, extra );
}
},
set: function( elem, value, extra ) {
var matches,
styles = getStyles( elem ),
// Only read styles.position if the test has a chance to fail
// to avoid forcing a reflow.
scrollboxSizeBuggy = !support.scrollboxSize() &&
styles.position === "absolute",
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
boxSizingNeeded = scrollboxSizeBuggy || extra,
isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
subtract = extra ?
boxModelAdjustment(
elem,
dimension,
extra,
isBorderBox,
styles
) :
0;
// Account for unreliable border-box dimensions by comparing offset* to computed and
// faking a content-box to get border and padding (gh-3699)
if ( isBorderBox && scrollboxSizeBuggy ) {
subtract -= Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
parseFloat( styles[ dimension ] ) -
boxModelAdjustment( elem, dimension, "border", false, styles ) -
0.5
);
}
// Convert to pixels if value adjustment is needed
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
( matches[ 3 ] || "px" ) !== "px" ) {
elem.style[ dimension ] = value;
value = jQuery.css( elem, dimension );
}
return setPositiveNumber( elem, value, subtract );
}
};
} );
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
function( elem, computed ) {
if ( computed ) {
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
elem.getBoundingClientRect().left -
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left;
} )
) + "px";
}
}
);
// These hooks are used by animate to expand properties
jQuery.each( {
margin: "",
padding: "",
border: "Width"
}, function( prefix, suffix ) {
jQuery.cssHooks[ prefix + suffix ] = {
expand: function( value ) {
var i = 0,
expanded = {},
// Assumes a single number if not a string
parts = typeof value === "string" ? value.split( " " ) : [ value ];
for ( ; i < 4; i++ ) {
expanded[ prefix + cssExpand[ i ] + suffix ] =
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
}
return expanded;
}
};
if ( prefix !== "margin" ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
}
} );
jQuery.fn.extend( {
css: function( name, value ) {
return access( this, function( elem, name, value ) {
var styles, len,
map = {},
i = 0;
if ( Array.isArray( name ) ) {
styles = getStyles( elem );
len = name.length;
for ( ; i < len; i++ ) {
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
}
return map;
}
return value !== undefined ?
jQuery.style( elem, name, value ) :
jQuery.css( elem, name );
}, name, value, arguments.length > 1 );
}
} );
function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing );
}
jQuery.Tween = Tween;
Tween.prototype = {
constructor: Tween,
init: function( elem, options, prop, end, easing, unit ) {
this.elem = elem;
this.prop = prop;
this.easing = easing || jQuery.easing._default;
this.options = options;
this.start = this.now = this.cur();
this.end = end;
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
},
cur: function() {
var hooks = Tween.propHooks[ this.prop ];
return hooks && hooks.get ?
hooks.get( this ) :
Tween.propHooks._default.get( this );
},
run: function( percent ) {
var eased,
hooks = Tween.propHooks[ this.prop ];
if ( this.options.duration ) {
this.pos = eased = jQuery.easing[ this.easing ](
percent, this.options.duration * percent, 0, 1, this.options.duration
);
} else {
this.pos = eased = percent;
}
this.now = ( this.end - this.start ) * eased + this.start;
if ( this.options.step ) {
this.options.step.call( this.elem, this.now, this );
}
if ( hooks && hooks.set ) {
hooks.set( this );
} else {
Tween.propHooks._default.set( this );
}
return this;
}
};
Tween.prototype.init.prototype = Tween.prototype;
Tween.propHooks = {
_default: {
get: function( tween ) {
var result;
// Use a property on the element directly when it is not a DOM element,
// or when there is no matching style property that exists.
if ( tween.elem.nodeType !== 1 ||
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
return tween.elem[ tween.prop ];
}
// Passing an empty string as a 3rd parameter to .css will automatically
// attempt a parseFloat and fallback to a string if the parse fails.
// Simple values such as "10px" are parsed to Float;
// complex values such as "rotate(1rad)" are returned as-is.
result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result;
},
set: function( tween ) {
// Use step hook for back compat.
// Use cssHook if its there.
// Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.nodeType === 1 && (
jQuery.cssHooks[ tween.prop ] ||
tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
} else {
tween.elem[ tween.prop ] = tween.now;
}
}
}
};
// Support: IE <=9 only
// Panic based approach to setting things on disconnected nodes
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
set: function( tween ) {
if ( tween.elem.nodeType && tween.elem.parentNode ) {
tween.elem[ tween.prop ] = tween.now;
}
}
};
jQuery.easing = {
linear: function( p ) {
return p;
},
swing: function( p ) {
return 0.5 - Math.cos( p * Math.PI ) / 2;
},
_default: "swing"
};
jQuery.fx = Tween.prototype.init;
// Back compat <1.8 extension point
jQuery.fx.step = {};
var
fxNow, inProgress,
rfxtypes = /^(?:toggle|show|hide)$/,
rrun = /queueHooks$/;
function schedule() {
if ( inProgress ) {
if ( document.hidden === false && window.requestAnimationFrame ) {
window.requestAnimationFrame( schedule );
} else {
window.setTimeout( schedule, jQuery.fx.interval );
}
jQuery.fx.tick();
}
}
// Animations created synchronously will run synchronously
function createFxNow() {
window.setTimeout( function() {
fxNow = undefined;
} );
return ( fxNow = Date.now() );
}
// Generate parameters to create a standard animation
function genFx( type, includeWidth ) {
var which,
i = 0,
attrs = { height: type };
// If we include width, step value is 1 to do all cssExpand values,
// otherwise step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}
if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}
return attrs;
}
function createTween( value, prop, animation ) {
var tween,
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
index = 0,
length = collection.length;
for ( ; index < length; index++ ) {
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// We're done with this property
return tween;
}
}
}
function defaultPrefilter( elem, props, opts ) {
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
isBox = "width" in props || "height" in props,
anim = this,
orig = {},
style = elem.style,
hidden = elem.nodeType && isHiddenWithinTree( elem ),
dataShow = dataPriv.get( elem, "fxshow" );
// Queue-skipping animations hijack the fx hooks
if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) {
hooks.unqueued = 0;
oldfire = hooks.empty.fire;
hooks.empty.fire = function() {
if ( !hooks.unqueued ) {
oldfire();
}
};
}
hooks.unqueued++;
anim.always( function() {
// Ensure the complete handler is called before this completes
anim.always( function() {
hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire();
}
} );
} );
}
// Detect show/hide animations
for ( prop in props ) {
value = props[ prop ];
if ( rfxtypes.test( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// Pretend to be hidden if this is a "show" and
// there is still data from a stopped show/hide
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true;
// Ignore all other no-op show/hide data
} else {
continue;
}
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
}
// Bail out if this is a no-op like .hide().hide()
propTween = !jQuery.isEmptyObject( props );
if ( !propTween && jQuery.isEmptyObject( orig ) ) {
return;
}
// Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) {
// Support: IE <=9 - 11, Edge 12 - 15
// Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY and Edge just mirrors
// the overflowX value there.
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Identify a display type, preferring old show/hide data over the CSS cascade
restoreDisplay = dataShow && dataShow.display;
if ( restoreDisplay == null ) {
restoreDisplay = dataPriv.get( elem, "display" );
}
display = jQuery.css( elem, "display" );
if ( display === "none" ) {
if ( restoreDisplay ) {
display = restoreDisplay;
} else {
// Get nonempty value(s) by temporarily forcing visibility
showHide( [ elem ], true );
restoreDisplay = elem.style.display || restoreDisplay;
display = jQuery.css( elem, "display" );
showHide( [ elem ] );
}
}
// Animate inline elements as inline-block
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
if ( jQuery.css( elem, "float" ) === "none" ) {
// Restore the original display value at the end of pure show/hide animations
if ( !propTween ) {
anim.done( function() {
style.display = restoreDisplay;
} );
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
}
}
style.display = "inline-block";
}
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
anim.always( function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
} );
}
// Implement show/hide animations
propTween = false;
for ( prop in orig ) {
// General show/hide setup for this element animation
if ( !propTween ) {
if ( dataShow ) {
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
}
} else {
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
}
// Store hidden/visible for toggle so `.stop().toggle()` "reverses"
if ( toggle ) {
dataShow.hidden = !hidden;
}
// Show elements before animating them
if ( hidden ) {
showHide( [ elem ], true );
}
/* eslint-disable no-loop-func */
anim.done( function() {
/* eslint-enable no-loop-func */
// The final step of a "hide" animation is actually hiding the element
if ( !hidden ) {
showHide( [ elem ] );
}
dataPriv.remove( elem, "fxshow" );
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
} );
}
// Per-property setup
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = propTween.start;
if ( hidden ) {
propTween.end = propTween.start;
propTween.start = 0;
}
}
}
}
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
name = camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( Array.isArray( value ) ) {
easing = value[ 1 ];
value = props[ index ] = value[ 0 ];
}
if ( index !== name ) {
props[ name ] = value;
delete props[ index ];
}
hooks = jQuery.cssHooks[ name ];
if ( hooks && "expand" in hooks ) {
value = hooks.expand( value );
delete props[ name ];
// Not quite $.extend, this won't overwrite existing keys.
// Reusing 'index' because we have the correct "name"
for ( index in value ) {
if ( !( index in props ) ) {
props[ index ] = value[ index ];
specialEasing[ index ] = easing;
}
}
} else {
specialEasing[ name ] = easing;
}
}
}
function Animation( elem, properties, options ) {
var result,
stopped,
index = 0,
length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() {
// Don't match elem in the :animated selector
delete tick.elem;
} ),
tick = function() {
if ( stopped ) {
return false;
}
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 only
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0,
percent = 1 - temp,
index = 0,
length = animation.tweens.length;
for ( ; index < length; index++ ) {
animation.tweens[ index ].run( percent );
}
deferred.notifyWith( elem, [ animation, percent, remaining ] );
// If there's more to do, yield
if ( percent < 1 && length ) {
return remaining;
}
// If this was an empty animation, synthesize a final progress notification
if ( !length ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
}
// Resolve the animation and report its conclusion
deferred.resolveWith( elem, [ animation ] );
return false;
},
animation = deferred.promise( {
elem: elem,
props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, {
specialEasing: {},
easing: jQuery.easing._default
}, options ),
originalProperties: properties,
originalOptions: options,
startTime: fxNow || createFxNow(),
duration: options.duration,
tweens: [],
createTween: function( prop, end ) {
var tween = jQuery.Tween( elem, animation.opts, prop, end,
animation.opts.specialEasing[ prop ] || animation.opts.easing );
animation.tweens.push( tween );
return tween;
},
stop: function( gotoEnd ) {
var index = 0,
// If we are going to the end, we want to run all the tweens
// otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0;
if ( stopped ) {
return this;
}
stopped = true;
for ( ; index < length; index++ ) {
animation.tweens[ index ].run( 1 );
}
// Resolve when we played the last frame; otherwise, reject
if ( gotoEnd ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else {
deferred.rejectWith( elem, [ animation, gotoEnd ] );
}
return this;
}
} ),
props = animation.props;
propFilter( props, animation.opts.specialEasing );
for ( ; index < length; index++ ) {
result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
if ( result ) {
if ( isFunction( result.stop ) ) {
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
result.stop.bind( result );
}
return result;
}
}
jQuery.map( props, createTween, animation );
if ( isFunction( animation.opts.start ) ) {
animation.opts.start.call( elem, animation );
}
// Attach callbacks from options
animation
.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
.fail( animation.opts.fail )
.always( animation.opts.always );
jQuery.fx.timer(
jQuery.extend( tick, {
elem: elem,
anim: animation,
queue: animation.opts.queue
} )
);
return animation;
}
jQuery.Animation = jQuery.extend( Animation, {
tweeners: {
"*": [ function( prop, value ) {
var tween = this.createTween( prop, value );
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
return tween;
} ]
},
tweener: function( props, callback ) {
if ( isFunction( props ) ) {
callback = props;
props = [ "*" ];
} else {
props = props.match( rnothtmlwhite );
}
var prop,
index = 0,
length = props.length;
for ( ; index < length; index++ ) {
prop = props[ index ];
Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
Animation.tweeners[ prop ].unshift( callback );
}
},
prefilters: [ defaultPrefilter ],
prefilter: function( callback, prepend ) {
if ( prepend ) {
Animation.prefilters.unshift( callback );
} else {
Animation.prefilters.push( callback );
}
}
} );
jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
complete: fn || !fn && easing ||
isFunction( speed ) && speed,
duration: speed,
easing: fn && easing || easing && !isFunction( easing ) && easing
};
// Go to the end state if fx are off
if ( jQuery.fx.off ) {
opt.duration = 0;
} else {
if ( typeof opt.duration !== "number" ) {
if ( opt.duration in jQuery.fx.speeds ) {
opt.duration = jQuery.fx.speeds[ opt.duration ];
} else {
opt.duration = jQuery.fx.speeds._default;
}
}
}
// Normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) {
opt.queue = "fx";
}
// Queueing
opt.old = opt.complete;
opt.complete = function() {
if ( isFunction( opt.old ) ) {
opt.old.call( this );
}
if ( opt.queue ) {
jQuery.dequeue( this, opt.queue );
}
};
return opt;
};
jQuery.fn.extend( {
fadeTo: function( speed, to, easing, callback ) {
// Show any hidden elements after setting opacity to 0
return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
// Animate to the value specified
.end().animate( { opacity: to }, speed, easing, callback );
},
animate: function( prop, speed, easing, callback ) {
var empty = jQuery.isEmptyObject( prop ),
optall = jQuery.speed( speed, easing, callback ),
doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
// Empty animations, or finishing resolves immediately
if ( empty || dataPriv.get( this, "finish" ) ) {
anim.stop( true );
}
};
doAnimation.finish = doAnimation;
return empty || optall.queue === false ?
this.each( doAnimation ) :
this.queue( optall.queue, doAnimation );
},
stop: function( type, clearQueue, gotoEnd ) {
var stopQueue = function( hooks ) {
var stop = hooks.stop;
delete hooks.stop;
stop( gotoEnd );
};
if ( typeof type !== "string" ) {
gotoEnd = clearQueue;
clearQueue = type;
type = undefined;
}
if ( clearQueue && type !== false ) {
this.queue( type || "fx", [] );
}
return this.each( function() {
var dequeue = true,
index = type != null && type + "queueHooks",
timers = jQuery.timers,
data = dataPriv.get( this );
if ( index ) {
if ( data[ index ] && data[ index ].stop ) {
stopQueue( data[ index ] );
}
} else {
for ( index in data ) {
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
stopQueue( data[ index ] );
}
}
}
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this &&
( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd );
dequeue = false;
timers.splice( index, 1 );
}
}
// Start the next in the queue if the last step wasn't forced.
// Timers currently will call their complete callbacks, which
// will dequeue but only if they were gotoEnd.
if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type );
}
} );
},
finish: function( type ) {
if ( type !== false ) {
type = type || "fx";
}
return this.each( function() {
var index,
data = dataPriv.get( this ),
queue = data[ type + "queue" ],
hooks = data[ type + "queueHooks" ],
timers = jQuery.timers,
length = queue ? queue.length : 0;
// Enable finishing flag on private data
data.finish = true;
// Empty the queue first
jQuery.queue( this, type, [] );
if ( hooks && hooks.stop ) {
hooks.stop.call( this, true );
}
// Look for any active animations, and finish them
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
timers[ index ].anim.stop( true );
timers.splice( index, 1 );
}
}
// Look for any animations in the old queue and finish them
for ( index = 0; index < length; index++ ) {
if ( queue[ index ] && queue[ index ].finish ) {
queue[ index ].finish.call( this );
}
}
// Turn off finishing flag
delete data.finish;
} );
}
} );
jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) {
return speed == null || typeof speed === "boolean" ?
cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback );
};
} );
// Generate shortcuts for custom animations
jQuery.each( {
slideDown: genFx( "show" ),
slideUp: genFx( "hide" ),
slideToggle: genFx( "toggle" ),
fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" }
}, function( name, props ) {
jQuery.fn[ name ] = function( speed, easing, callback ) {
return this.animate( props, speed, easing, callback );
};
} );
jQuery.timers = [];
jQuery.fx.tick = function() {
var timer,
i = 0,
timers = jQuery.timers;
fxNow = Date.now();
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
// Run the timer and safely remove it when done (allowing for external removal)
if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 );
}
}
if ( !timers.length ) {
jQuery.fx.stop();
}
fxNow = undefined;
};
jQuery.fx.timer = function( timer ) {
jQuery.timers.push( timer );
jQuery.fx.start();
};
jQuery.fx.interval = 13;
jQuery.fx.start = function() {
if ( inProgress ) {
return;
}
inProgress = true;
schedule();
};
jQuery.fx.stop = function() {
inProgress = null;
};
jQuery.fx.speeds = {
slow: 600,
fast: 200,
// Default speed
_default: 400
};
// Based off of the plugin by Clint Helfers, with permission.
// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
jQuery.fn.delay = function( time, type ) {
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
type = type || "fx";
return this.queue( type, function( next, hooks ) {
var timeout = window.setTimeout( next, time );
hooks.stop = function() {
window.clearTimeout( timeout );
};
} );
};
( function() {
var input = document.createElement( "input" ),
select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) );
input.type = "checkbox";
// Support: Android <=4.3 only
// Default value for a checkbox should be "on"
support.checkOn = input.value !== "";
// Support: IE <=11 only
// Must access selectedIndex to make default options select
support.optSelected = opt.selected;
// Support: IE <=11 only
// An input loses its value after becoming a radio
input = document.createElement( "input" );
input.value = "t";
input.type = "radio";
support.radioValue = input.value === "t";
} )();
var boolHook,
attrHandle = jQuery.expr.attrHandle;
jQuery.fn.extend( {
attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 );
},
removeAttr: function( name ) {
return this.each( function() {
jQuery.removeAttr( this, name );
} );
}
} );
jQuery.extend( {
attr: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set attributes on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
// Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value );
}
// Attribute hooks are determined by the lowercase version
// Grab necessary hook if one is defined
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
}
if ( value !== undefined ) {
if ( value === null ) {
jQuery.removeAttr( elem, name );
return;
}
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
elem.setAttribute( name, value + "" );
return value;
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
ret = jQuery.find.attr( elem, name );
// Non-existent attributes return null, we normalize to undefined
return ret == null ? undefined : ret;
},
attrHooks: {
type: {
set: function( elem, value ) {
if ( !support.radioValue && value === "radio" &&
nodeName( elem, "input" ) ) {
var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
}
return value;
}
}
}
},
removeAttr: function( elem, value ) {
var name,
i = 0,
// Attribute names can contain non-HTML whitespace characters
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
attrNames = value && value.match( rnothtmlwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) {
elem.removeAttribute( name );
}
}
}
} );
// Hooks for boolean attributes
boolHook = {
set: function( elem, value, name ) {
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else {
elem.setAttribute( name, name );
}
return name;
}
};
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
var getter = attrHandle[ name ] || jQuery.find.attr;
attrHandle[ name ] = function( elem, name, isXML ) {
var ret, handle,
lowercaseName = name.toLowerCase();
if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter
handle = attrHandle[ lowercaseName ];
attrHandle[ lowercaseName ] = ret;
ret = getter( elem, name, isXML ) != null ?
lowercaseName :
null;
attrHandle[ lowercaseName ] = handle;
}
return ret;
};
} );
var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
jQuery.fn.extend( {
prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ];
} );
}
} );
jQuery.extend( {
prop: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
return ( elem[ name ] = value );
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
return elem[ name ];
},
propHooks: {
tabIndex: {
get: function( elem ) {
// Support: IE <=9 - 11 only
// elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
// Use proper attribute retrieval(#12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
if ( tabindex ) {
return parseInt( tabindex, 10 );
}
if (
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) &&
elem.href
) {
return 0;
}
return -1;
}
}
},
propFix: {
"for": "htmlFor",
"class": "className"
}
} );
// Support: IE <=11 only
// Accessing the selectedIndex property
// forces the browser to respect setting selected
// on the option
// The getter ensures a default option is selected
// when in an optgroup
// eslint rule "no-unused-expressions" is disabled for this code
// since it considers such accessions noop
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode;
if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex;
}
return null;
},
set: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode;
if ( parent ) {
parent.selectedIndex;
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
}
}
};
}
jQuery.each( [
"tabIndex",
"readOnly",
"maxLength",
"cellSpacing",
"cellPadding",
"rowSpan",
"colSpan",
"useMap",
"frameBorder",
"contentEditable"
], function() {
jQuery.propFix[ this.toLowerCase() ] = this;
} );
// Strip and collapse whitespace according to HTML spec
// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
function stripAndCollapse( value ) {
var tokens = value.match( rnothtmlwhite ) || [];
return tokens.join( " " );
}
function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
function classesToArray( value ) {
if ( Array.isArray( value ) ) {
return value;
}
if ( typeof value === "string" ) {
return value.match( rnothtmlwhite ) || [];
}
return [];
}
jQuery.fn.extend( {
addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
} );
}
classes = classesToArray( value );
if ( classes.length ) {
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
j = 0;
while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue );
}
}
}
}
return this;
},
removeClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
} );
}
if ( !arguments.length ) {
return this.attr( "class", "" );
}
classes = classesToArray( value );
if ( classes.length ) {
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
// This expression is here for better compressibility (see addClass)
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
j = 0;
while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " );
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue );
}
}
}
}
return this;
},
toggleClass: function( value, stateVal ) {
var type = typeof value,
isValidValue = type === "string" || Array.isArray( value );
if ( typeof stateVal === "boolean" && isValidValue ) {
return stateVal ? this.addClass( value ) : this.removeClass( value );
}
if ( isFunction( value ) ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
stateVal
);
} );
}
return this.each( function() {
var className, i, self, classNames;
if ( isValidValue ) {
// Toggle individual class names
i = 0;
self = jQuery( this );
classNames = classesToArray( value );
while ( ( className = classNames[ i++ ] ) ) {
// Check each className given, space separated list
if ( self.hasClass( className ) ) {
self.removeClass( className );
} else {
self.addClass( className );
}
}
// Toggle whole class name
} else if ( value === undefined || type === "boolean" ) {
className = getClass( this );
if ( className ) {
// Store className if set
dataPriv.set( this, "__className__", className );
}
// If the element has a class name or if we're passed `false`,
// then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored.
if ( this.setAttribute ) {
this.setAttribute( "class",
className || value === false ?
"" :
dataPriv.get( this, "__className__" ) || ""
);
}
}
} );
},
hasClass: function( selector ) {
var className, elem,
i = 0;
className = " " + selector + " ";
while ( ( elem = this[ i++ ] ) ) {
if ( elem.nodeType === 1 &&
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
return true;
}
}
return false;
}
} );
var rreturn = /\r/g;
jQuery.fn.extend( {
val: function( value ) {
var hooks, ret, valueIsFunction,
elem = this[ 0 ];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret;
}
ret = elem.value;
// Handle most common string cases
if ( typeof ret === "string" ) {
return ret.replace( rreturn, "" );
}
// Handle cases where value is null/undef or number
return ret == null ? "" : ret;
}
return;
}
valueIsFunction = isFunction( value );
return this.each( function( i ) {
var val;
if ( this.nodeType !== 1 ) {
return;
}
if ( valueIsFunction ) {
val = value.call( this, i, jQuery( this ).val() );
} else {
val = value;
}
// Treat null/undefined as ""; convert numbers to string
if ( val == null ) {
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( Array.isArray( val ) ) {
val = jQuery.map( val, function( value ) {
return value == null ? "" : value + "";
} );
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
} );
}
} );
jQuery.extend( {
valHooks: {
option: {
get: function( elem ) {
var val = jQuery.find.attr( elem, "value" );
return val != null ?
val :
// Support: IE <=10 - 11 only
// option.text throws exceptions (#14686, #14858)
// Strip and collapse whitespace
// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
stripAndCollapse( jQuery.text( elem ) );
}
},
select: {
get: function( elem ) {
var value, option, i,
options = elem.options,
index = elem.selectedIndex,
one = elem.type === "select-one",
values = one ? null : [],
max = one ? index + 1 : options.length;
if ( index < 0 ) {
i = max;
} else {
i = one ? index : 0;
}
// Loop through all the selected options
for ( ; i < max; i++ ) {
option = options[ i ];
// Support: IE <=9 only
// IE8-9 doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup
!option.disabled &&
( !option.parentNode.disabled ||
!nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
value = jQuery( option ).val();
// We don't need an array for one selects
if ( one ) {
return value;
}
// Multi-Selects return an array
values.push( value );
}
}
return values;
},
set: function( elem, value ) {
var optionSet, option,
options = elem.options,
values = jQuery.makeArray( value ),
i = options.length;
while ( i-- ) {
option = options[ i ];
/* eslint-disable no-cond-assign */
if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true;
}
/* eslint-enable no-cond-assign */
}
// Force browsers to behave consistently when non-matching value is set
if ( !optionSet ) {
elem.selectedIndex = -1;
}
return values;
}
}
}
} );
// Radios and checkboxes getter/setter
jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = {
set: function( elem, value ) {
if ( Array.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
}
}
};
if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute( "value" ) === null ? "on" : elem.value;
};
}
} );
// Return jQuery for attributes-only inclusion
support.focusin = "onfocusin" in window;
var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
stopPropagationCallback = function( e ) {
e.stopPropagation();
};
jQuery.extend( jQuery.event, {
trigger: function( event, data, elem, onlyHandlers ) {
var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = lastElement = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split( "." );
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (#9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
lastElement = cur;
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
dataPriv.get( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
}
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( ( !special._default ||
special._default.apply( eventPath.pop(), data ) === false ) &&
acceptData( elem ) ) {
// Call a native DOM method on the target with the same name as the event.
// Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
if ( event.isPropagationStopped() ) {
lastElement.addEventListener( type, stopPropagationCallback );
}
elem[ type ]();
if ( event.isPropagationStopped() ) {
lastElement.removeEventListener( type, stopPropagationCallback );
}
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
}
return event.result;
},
// Piggyback on a donor event to simulate a different one
// Used only for `focus(in | out)` events
simulate: function( type, elem, event ) {
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true
}
);
jQuery.event.trigger( e, null, elem );
}
} );
jQuery.fn.extend( {
trigger: function( type, data ) {
return this.each( function() {
jQuery.event.trigger( type, data, this );
} );
},
triggerHandler: function( type, data ) {
var elem = this[ 0 ];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
}
} );
// Support: Firefox <=44
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
//
// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
// focus(in | out) events fire after focus & blur events,
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
};
jQuery.event.special[ fix ] = {
setup: function() {
var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix );
if ( !attaches ) {
doc.addEventListener( orig, handler, true );
}
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix ) - 1;
if ( !attaches ) {
doc.removeEventListener( orig, handler, true );
dataPriv.remove( doc, fix );
} else {
dataPriv.access( doc, fix, attaches );
}
}
};
} );
}
var location = window.location;
var nonce = Date.now();
var rquery = ( /\?/ );
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
var xml;
if ( !data || typeof data !== "string" ) {
return null;
}
// Support: IE 9 - 11 only
// IE throws on parseFromString with invalid input.
try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
} catch ( e ) {
xml = undefined;
}
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data );
}
return xml;
};
var
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
rsubmittable = /^(?:input|select|textarea|keygen)/i;
function buildParams( prefix, obj, traditional, add ) {
var name;
if ( Array.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
} else {
// Item is non-scalar (array or object), encode its numeric index.
buildParams(
prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
v,
traditional,
add
);
}
} );
} else if ( !traditional && toType( obj ) === "object" ) {
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
// Serialize scalar item.
add( prefix, obj );
}
}
// Serialize an array of form elements or a set of
// key/values into a query string
jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, valueOrFunction ) {
// If value is a function, invoke it and use its return value
var value = isFunction( valueOrFunction ) ?
valueOrFunction() :
valueOrFunction;
s[ s.length ] = encodeURIComponent( key ) + "=" +
encodeURIComponent( value == null ? "" : value );
};
if ( a == null ) {
return "";
}
// If an array was passed in, assume that it is an array of form elements.
if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
} );
} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
}
}
// Return the resulting serialization
return s.join( "&" );
};
jQuery.fn.extend( {
serialize: function() {
return jQuery.param( this.serializeArray() );
},
serializeArray: function() {
return this.map( function() {
// Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this;
} )
.filter( function() {
var type = this.type;
// Use .is( ":disabled" ) so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
} )
.map( function( i, elem ) {
var val = jQuery( this ).val();
if ( val == null ) {
return null;
}
if ( Array.isArray( val ) ) {
return jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
} );
}
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
} ).get();
}
} );
var
r20 = /%20/g,
rhash = /#.*$/,
rantiCache = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
// #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//,
/* Prefilters
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
* 2) These are called:
* - BEFORE asking for a transport
* - AFTER param serialization (s.data is a string if s.processData is true)
* 3) key is the dataType
* 4) the catchall symbol "*" can be used
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
*/
prefilters = {},
/* Transports bindings
* 1) key is the dataType
* 2) the catchall symbol "*" can be used
* 3) selection will start with transport dataType and THEN go to "*" if needed
*/
transports = {},
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = "*/".concat( "*" ),
// Anchor tag for parsing the document origin
originAnchor = document.createElement( "a" );
originAnchor.href = location.href;
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {
// dataTypeExpression is optional and defaults to "*"
return function( dataTypeExpression, func ) {
if ( typeof dataTypeExpression !== "string" ) {
func = dataTypeExpression;
dataTypeExpression = "*";
}
var dataType,
i = 0,
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
if ( isFunction( func ) ) {
// For each dataType in the dataTypeExpression
while ( ( dataType = dataTypes[ i++ ] ) ) {
// Prepend if requested
if ( dataType[ 0 ] === "+" ) {
dataType = dataType.slice( 1 ) || "*";
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
// Otherwise append
} else {
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
}
}
}
};
}
// Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
var inspected = {},
seekingTransport = ( structure === transports );
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport );
return false;
} else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport );
}
} );
return selected;
}
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
}
// A special extend for ajax options
// that takes "flat" options (not to be deep extended)
// Fixes #9887
function ajaxExtend( target, src ) {
var key, deep,
flatOptions = jQuery.ajaxSettings.flatOptions || {};
for ( key in src ) {
if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
}
}
if ( deep ) {
jQuery.extend( true, target, deep );
}
return target;
}
/* Handles responses to an ajax request:
* - finds the right dataType (mediates between content-type and expected dataType)
* - returns the corresponding response
*/
function ajaxHandleResponses( s, jqXHR, responses ) {
var ct, type, finalDataType, firstDataType,
contents = s.contents,
dataTypes = s.dataTypes;
// Remove auto dataType and get content-type in the process
while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
}
}
// Check if we're dealing with a known content-type
if ( ct ) {
for ( type in contents ) {
if ( contents[ type ] && contents[ type ].test( ct ) ) {
dataTypes.unshift( type );
break;
}
}
}
// Check to see if we have a response for the expected dataType
if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ];
} else {
// Try convertible dataTypes
for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type;
break;
}
if ( !firstDataType ) {
firstDataType = type;
}
}
// Or just use first one
finalDataType = finalDataType || firstDataType;
}
// If we found a dataType
// We add the dataType to the list if needed
// and return the corresponding response
if ( finalDataType ) {
if ( finalDataType !== dataTypes[ 0 ] ) {
dataTypes.unshift( finalDataType );
}
return responses[ finalDataType ];
}
}
/* Chain conversions given the request and the original response
* Also sets the responseXXX fields on the jqXHR instance
*/
function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev,
converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice();
// Create converters map with lowercased keys
if ( dataTypes[ 1 ] ) {
for ( conv in s.converters ) {
converters[ conv.toLowerCase() ] = s.converters[ conv ];
}
}
current = dataTypes.shift();
// Convert to each sequential dataType
while ( current ) {
if ( s.responseFields[ current ] ) {
jqXHR[ s.responseFields[ current ] ] = response;
}
// Apply the dataFilter if provided
if ( !prev && isSuccess && s.dataFilter ) {
response = s.dataFilter( response, s.dataType );
}
prev = current;
current = dataTypes.shift();
if ( current ) {
// There's only work to do if current dataType is non-auto
if ( current === "*" ) {
current = prev;
// Convert response if prev dataType is non-auto and differs from current
} else if ( prev !== "*" && prev !== current ) {
// Seek a direct converter
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
// If none found, seek a pair
if ( !conv ) {
for ( conv2 in converters ) {
// If conv2 outputs current
tmp = conv2.split( " " );
if ( tmp[ 1 ] === current ) {
// If prev can be converted to accepted input
conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ];
if ( conv ) {
// Condense equivalence converters
if ( conv === true ) {
conv = converters[ conv2 ];
// Otherwise, insert the intermediate dataType
} else if ( converters[ conv2 ] !== true ) {
current = tmp[ 0 ];
dataTypes.unshift( tmp[ 1 ] );
}
break;
}
}
}
}
// Apply converter (if not an equivalence)
if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them
if ( conv && s.throws ) {
response = conv( response );
} else {
try {
response = conv( response );
} catch ( e ) {
return {
state: "parsererror",
error: conv ? e : "No conversion from " + prev + " to " + current
};
}
}
}
}
}
}
return { state: "success", data: response };
}
jQuery.extend( {
// Counter for holding the number of active queries
active: 0,
// Last-Modified header cache for next request
lastModified: {},
etag: {},
ajaxSettings: {
url: location.href,
type: "GET",
isLocal: rlocalProtocol.test( location.protocol ),
global: true,
processData: true,
async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
/*
timeout: 0,
data: null,
dataType: null,
username: null,
password: null,
cache: null,
throws: false,
traditional: false,
headers: {},
*/
accepts: {
"*": allTypes,
text: "text/plain",
html: "text/html",
xml: "application/xml, text/xml",
json: "application/json, text/javascript"
},
contents: {
xml: /\bxml\b/,
html: /\bhtml/,
json: /\bjson\b/
},
responseFields: {
xml: "responseXML",
text: "responseText",
json: "responseJSON"
},
// Data converters
// Keys separate source (or catchall "*") and destination types with a single space
converters: {
// Convert anything to text
"* text": String,
// Text to html (true = no transformation)
"text html": true,
// Evaluate text as a json expression
"text json": JSON.parse,
// Parse text as xml
"text xml": jQuery.parseXML
},
// For options that shouldn't be deep extended:
// you can add your own custom options here if
// and when you create one that shouldn't be
// deep extended (see ajaxExtend)
flatOptions: {
url: true,
context: true
}
},
// Creates a full fledged settings object into target
// with both ajaxSettings and settings fields.
// If target is omitted, writes into ajaxSettings.
ajaxSetup: function( target, settings ) {
return settings ?
// Building a settings object
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
// Extending ajaxSettings
ajaxExtend( jQuery.ajaxSettings, target );
},
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
ajaxTransport: addToPrefiltersOrTransports( transports ),
// Main method
ajax: function( url, options ) {
// If url is an object, simulate pre-1.5 signature
if ( typeof url === "object" ) {
options = url;
url = undefined;
}
// Force options to be an object
options = options || {};
var transport,
// URL without anti-cache param
cacheURL,
// Response headers
responseHeadersString,
responseHeaders,
// timeout handle
timeoutTimer,
// Url cleanup var
urlAnchor,
// Request state (becomes false upon send and true upon completion)
completed,
// To know if global events are to be dispatched
fireGlobals,
// Loop variable
i,
// uncached part of the url
uncached,
// Create the final options object
s = jQuery.ajaxSetup( {}, options ),
// Callbacks context
callbackContext = s.context || s,
// Context for global events is callbackContext if it is a DOM node or jQuery collection
globalEventContext = s.context &&
( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery( callbackContext ) :
jQuery.event,
// Deferreds
deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks
statusCode = s.statusCode || {},
// Headers (they are sent all at once)
requestHeaders = {},
requestHeadersNames = {},
// Default abort message
strAbort = "canceled",
// Fake xhr
jqXHR = {
readyState: 0,
// Builds headers hashtable if needed
getResponseHeader: function( key ) {
var match;
if ( completed ) {
if ( !responseHeaders ) {
responseHeaders = {};
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
.concat( match[ 2 ] );
}
}
match = responseHeaders[ key.toLowerCase() + " " ];
}
return match == null ? null : match.join( ", " );
},
// Raw string
getAllResponseHeaders: function() {
return completed ? responseHeadersString : null;
},
// Caches the header
setRequestHeader: function( name, value ) {
if ( completed == null ) {
name = requestHeadersNames[ name.toLowerCase() ] =
requestHeadersNames[ name.toLowerCase() ] || name;
requestHeaders[ name ] = value;
}
return this;
},
// Overrides response content-type header
overrideMimeType: function( type ) {
if ( completed == null ) {
s.mimeType = type;
}
return this;
},
// Status-dependent callbacks
statusCode: function( map ) {
var code;
if ( map ) {
if ( completed ) {
// Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] );
} else {
// Lazy-add the new callbacks in a way that preserves old ones
for ( code in map ) {
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
}
}
return this;
},
// Cancel the request
abort: function( statusText ) {
var finalText = statusText || strAbort;
if ( transport ) {
transport.abort( finalText );
}
done( 0, finalText );
return this;
}
};
// Attach deferreds
deferred.promise( jqXHR );
// Add protocol if not provided (prefilters might expect it)
// Handle falsy url in the settings object (#10093: consistency with old signature)
// We also use the url parameter if available
s.url = ( ( url || s.url || location.href ) + "" )
.replace( rprotocol, location.protocol + "//" );
// Alias method option to type as per ticket #12004
s.type = options.method || options.type || s.method || s.type;
// Extract dataTypes list
s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
// A cross-domain request is in order when the origin doesn't match the current origin.
if ( s.crossDomain == null ) {
urlAnchor = document.createElement( "a" );
// Support: IE <=8 - 11, Edge 12 - 15
// IE throws exception on accessing the href property if url is malformed,
// e.g. http://example.com:80x/
try {
urlAnchor.href = s.url;
// Support: IE <=8 - 11 only
// Anchor's host property isn't correctly set when s.url is relative
urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) {
// If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid
s.crossDomain = true;
}
}
// Convert data if not already a string
if ( s.data && s.processData && typeof s.data !== "string" ) {
s.data = jQuery.param( s.data, s.traditional );
}
// Apply prefilters
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
// If request was aborted inside a prefilter, stop there
if ( completed ) {
return jqXHR;
}
// We can fire global events as of now if asked to
// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
fireGlobals = jQuery.event && s.global;
// Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger( "ajaxStart" );
}
// Uppercase the type
s.type = s.type.toUpperCase();
// Determine if request has content
s.hasContent = !rnoContent.test( s.type );
// Save the URL in case we're toying with the If-Modified-Since
// and/or If-None-Match header later on
// Remove hash to simplify url manipulation
cacheURL = s.url.replace( rhash, "" );
// More options handling for requests with no content
if ( !s.hasContent ) {
// Remember the hash so we can put it back
uncached = s.url.slice( cacheURL.length );
// If data is available and should be processed, append data to url
if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
// #9682: remove data so that it's not used in an eventual retry
delete s.data;
}
// Add or update anti-cache param if needed
if ( s.cache === false ) {
cacheURL = cacheURL.replace( rantiCache, "$1" );
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
}
// Put hash and anti-cache on the URL that will be requested (gh-1732)
s.url = cacheURL + uncached;
// Change '%20' to '+' if this is encoded form body content (gh-2658)
} else if ( s.data && s.processData &&
( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
s.data = s.data.replace( r20, "+" );
}
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
if ( jQuery.lastModified[ cacheURL ] ) {
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
}
if ( jQuery.etag[ cacheURL ] ) {
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
}
}
// Set the correct header, if data is being sent
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
jqXHR.setRequestHeader( "Content-Type", s.contentType );
}
// Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader(
"Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ]
);
// Check for headers option
for ( i in s.headers ) {
jqXHR.setRequestHeader( i, s.headers[ i ] );
}
// Allow custom headers/mimetypes and early abort
if ( s.beforeSend &&
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
// Abort if not done already and return
return jqXHR.abort();
}
// Aborting is no longer a cancellation
strAbort = "abort";
// Install callbacks on deferreds
completeDeferred.add( s.complete );
jqXHR.done( s.success );
jqXHR.fail( s.error );
// Get transport
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
// If no transport, we auto-abort
if ( !transport ) {
done( -1, "No Transport" );
} else {
jqXHR.readyState = 1;
// Send global event
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
}
// If request was aborted inside ajaxSend, stop there
if ( completed ) {
return jqXHR;
}
// Timeout
if ( s.async && s.timeout > 0 ) {
timeoutTimer = window.setTimeout( function() {
jqXHR.abort( "timeout" );
}, s.timeout );
}
try {
completed = false;
transport.send( requestHeaders, done );
} catch ( e ) {
// Rethrow post-completion exceptions
if ( completed ) {
throw e;
}
// Propagate others as results
done( -1, e );
}
}
// Callback for when everything is done
function done( status, nativeStatusText, responses, headers ) {
var isSuccess, success, error, response, modified,
statusText = nativeStatusText;
// Ignore repeat invocations
if ( completed ) {
return;
}
completed = true;
// Clear timeout if it exists
if ( timeoutTimer ) {
window.clearTimeout( timeoutTimer );
}
// Dereference transport for early garbage collection
// (no matter how long the jqXHR object will be used)
transport = undefined;
// Cache response headers
responseHeadersString = headers || "";
// Set readyState
jqXHR.readyState = status > 0 ? 4 : 0;
// Determine if successful
isSuccess = status >= 200 && status < 300 || status === 304;
// Get response data
if ( responses ) {
response = ajaxHandleResponses( s, jqXHR, responses );
}
// Convert no matter what (that way responseXXX fields are always set)
response = ajaxConvert( s, response, jqXHR, isSuccess );
// If successful, handle type chaining
if ( isSuccess ) {
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified;
}
modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) {
jQuery.etag[ cacheURL ] = modified;
}
}
// if no content
if ( status === 204 || s.type === "HEAD" ) {
statusText = "nocontent";
// if not modified
} else if ( status === 304 ) {
statusText = "notmodified";
// If we have data, let's convert it
} else {
statusText = response.state;
success = response.data;
error = response.error;
isSuccess = !error;
}
} else {
// Extract error from statusText and normalize for non-aborts
error = statusText;
if ( status || !statusText ) {
statusText = "error";
if ( status < 0 ) {
status = 0;
}
}
}
// Set data for the fake xhr object
jqXHR.status = status;
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
// Success/Error
if ( isSuccess ) {
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
} else {
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
}
// Status-dependent callbacks
jqXHR.statusCode( statusCode );
statusCode = undefined;
if ( fireGlobals ) {
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
[ jqXHR, s, isSuccess ? success : error ] );
}
// Complete
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter
if ( !( --jQuery.active ) ) {
jQuery.event.trigger( "ajaxStop" );
}
}
}
return jqXHR;
},
getJSON: function( url, data, callback ) {
return jQuery.get( url, data, callback, "json" );
},
getScript: function( url, callback ) {
return jQuery.get( url, undefined, callback, "script" );
}
} );
jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) {
// Shift arguments if data argument was omitted
if ( isFunction( data ) ) {
type = type || callback;
callback = data;
data = undefined;
}
// The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend( {
url: url,
type: method,
dataType: type,
data: data,
success: callback
}, jQuery.isPlainObject( url ) && url ) );
};
} );
jQuery._evalUrl = function( url, options ) {
return jQuery.ajax( {
url: url,
// Make this explicit, since user can override this through ajaxSetup (#11264)
type: "GET",
dataType: "script",
cache: true,
async: false,
global: false,
// Only evaluate the response if it is successful (gh-4126)
// dataFilter is not invoked for failure responses, so using it instead
// of the default converter is kludgy but it works.
converters: {
"text script": function() {}
},
dataFilter: function( response ) {
jQuery.globalEval( response, options );
}
} );
};
jQuery.fn.extend( {
wrapAll: function( html ) {
var wrap;
if ( this[ 0 ] ) {
if ( isFunction( html ) ) {
html = html.call( this[ 0 ] );
}
// The elements to wrap the target around
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
if ( this[ 0 ].parentNode ) {
wrap.insertBefore( this[ 0 ] );
}
wrap.map( function() {
var elem = this;
while ( elem.firstElementChild ) {
elem = elem.firstElementChild;
}
return elem;
} ).append( this );
}
return this;
},
wrapInner: function( html ) {
if ( isFunction( html ) ) {
return this.each( function( i ) {
jQuery( this ).wrapInner( html.call( this, i ) );
} );
}
return this.each( function() {
var self = jQuery( this ),
contents = self.contents();
if ( contents.length ) {
contents.wrapAll( html );
} else {
self.append( html );
}
} );
},
wrap: function( html ) {
var htmlIsFunction = isFunction( html );
return this.each( function( i ) {
jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
} );
},
unwrap: function( selector ) {
this.parent( selector ).not( "body" ).each( function() {
jQuery( this ).replaceWith( this.childNodes );
} );
return this;
}
} );
jQuery.expr.pseudos.hidden = function( elem ) {
return !jQuery.expr.pseudos.visible( elem );
};
jQuery.expr.pseudos.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
};
jQuery.ajaxSettings.xhr = function() {
try {
return new window.XMLHttpRequest();
} catch ( e ) {}
};
var xhrSuccessStatus = {
// File protocol always yields status code 0, assume 200
0: 200,
// Support: IE <=9 only
// #1450: sometimes IE returns 1223 when it should be 204
1223: 204
},
xhrSupported = jQuery.ajaxSettings.xhr();
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported;
jQuery.ajaxTransport( function( options ) {
var callback, errorCallback;
// Cross domain only allowed if supported through XMLHttpRequest
if ( support.cors || xhrSupported && !options.crossDomain ) {
return {
send: function( headers, complete ) {
var i,
xhr = options.xhr();
xhr.open(
options.type,
options.url,
options.async,
options.username,
options.password
);
// Apply custom fields if provided
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
}
}
// Override mime type if needed
if ( options.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( options.mimeType );
}
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Set headers
for ( i in headers ) {
xhr.setRequestHeader( i, headers[ i ] );
}
// Callback
callback = function( type ) {
return function() {
if ( callback ) {
callback = errorCallback = xhr.onload =
xhr.onerror = xhr.onabort = xhr.ontimeout =
xhr.onreadystatechange = null;
if ( type === "abort" ) {
xhr.abort();
} else if ( type === "error" ) {
// Support: IE <=9 only
// On a manual native abort, IE9 throws
// errors on any property access that is not readyState
if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
}
} else {
complete(
xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText,
// Support: IE <=9 only
// IE9 has no XHR2 but throws on binary (trac-11426)
// For XHR2 non-text, let the caller handle it (gh-2498)
( xhr.responseType || "text" ) !== "text" ||
typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders()
);
}
}
};
};
// Listen to events
xhr.onload = callback();
errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
// Support: IE 9 only
// Use onreadystatechange to replace onabort
// to handle uncaught aborts
if ( xhr.onabort !== undefined ) {
xhr.onabort = errorCallback;
} else {
xhr.onreadystatechange = function() {
// Check readyState before timeout as it changes
if ( xhr.readyState === 4 ) {
// Allow onerror to be called first,
// but that will not handle a native abort
// Also, save errorCallback to a variable
// as xhr.onerror cannot be accessed
window.setTimeout( function() {
if ( callback ) {
errorCallback();
}
} );
}
};
}
// Create the abort callback
callback = callback( "abort" );
try {
// Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null );
} catch ( e ) {
// #14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) {
throw e;
}
}
},
abort: function() {
if ( callback ) {
callback();
}
}
};
}
} );
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );
// Install script dataType
jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /\b(?:java|ecma)script\b/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text );
return text;
}
}
} );
// Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.cache === undefined ) {
s.cache = false;
}
if ( s.crossDomain ) {
s.type = "GET";
}
} );
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain or forced-by-attrs requests
if ( s.crossDomain || s.scriptAttrs ) {
var script, callback;
return {
send: function( _, complete ) {
script = jQuery( "<script>" )
.attr( s.scriptAttrs || {} )
.prop( { charset: s.scriptCharset, src: s.url } )
.on( "load error", callback = function( evt ) {
script.remove();
callback = null;
if ( evt ) {
complete( evt.type === "error" ? 404 : 200, evt.type );
}
} );
// Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] );
},
abort: function() {
if ( callback ) {
callback();
}
}
};
}
} );
var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" :
typeof s.data === "string" &&
( s.contentType || "" )
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
);
// Handle iff the expected data type is "jsonp" or we have a parameter to set
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
// Get callback name, remembering preexisting value associated with it
callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
s.jsonpCallback() :
s.jsonpCallback;
// Insert callback into url or form data
if ( jsonProp ) {
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
} else if ( s.jsonp !== false ) {
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
}
// Use data converter to retrieve json after script execution
s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
return responseContainer[ 0 ];
};
// Force json dataType
s.dataTypes[ 0 ] = "json";
// Install callback
overwritten = window[ callbackName ];
window[ callbackName ] = function() {
responseContainer = arguments;
};
// Clean-up function (fires after converters)
jqXHR.always( function() {
// If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
// Otherwise restore preexisting value
} else {
window[ callbackName ] = overwritten;
}
// Save back as free
if ( s[ callbackName ] ) {
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
// Save the callback name for future use
oldCallbacks.push( callbackName );
}
// Call if it was a function and we have a response
if ( responseContainer && isFunction( overwritten ) ) {
overwritten( responseContainer[ 0 ] );
}
responseContainer = overwritten = undefined;
} );
// Delegate to script
return "script";
}
} );
// Support: Safari 8 only
// In Safari 8 documents created via document.implementation.createHTMLDocument
// collapse sibling forms: the second one becomes a child of the first one.
// Because of that, this security measure has to be disabled in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = ( function() {
var body = document.implementation.createHTMLDocument( "" ).body;
body.innerHTML = "<form></form><form></form>";
return body.childNodes.length === 2;
} )();
// Argument "data" should be string of html
// context (optional): If specified, the fragment will be created in this context,
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) {
if ( typeof data !== "string" ) {
return [];
}
if ( typeof context === "boolean" ) {
keepScripts = context;
context = false;
}
var base, parsed, scripts;
if ( !context ) {
// Stop scripts or inline event handlers from being executed immediately
// by using document.implementation
if ( support.createHTMLDocument ) {
context = document.implementation.createHTMLDocument( "" );
// Set the base href for the created document
// so any parsed elements with URLs
// are based on the document's URL (gh-2965)
base = context.createElement( "base" );
base.href = document.location.href;
context.head.appendChild( base );
} else {
context = document;
}
}
parsed = rsingleTag.exec( data );
scripts = !keepScripts && [];
// Single tag
if ( parsed ) {
return [ context.createElement( parsed[ 1 ] ) ];
}
parsed = buildFragment( [ data ], context, scripts );
if ( scripts && scripts.length ) {
jQuery( scripts ).remove();
}
return jQuery.merge( [], parsed.childNodes );
};
/**
* Load a url into a page
*/
jQuery.fn.load = function( url, params, callback ) {
var selector, type, response,
self = this,
off = url.indexOf( " " );
if ( off > -1 ) {
selector = stripAndCollapse( url.slice( off ) );
url = url.slice( 0, off );
}
// If it's a function
if ( isFunction( params ) ) {
// We assume that it's the callback
callback = params;
params = undefined;
// Otherwise, build a param string
} else if ( params && typeof params === "object" ) {
type = "POST";
}
// If we have elements to modify, make the request
if ( self.length > 0 ) {
jQuery.ajax( {
url: url,
// If "type" variable is undefined, then "GET" method will be used.
// Make value of this field explicit since
// user can override it through ajaxSetup method
type: type || "GET",
dataType: "html",
data: params
} ).done( function( responseText ) {
// Save response for use in complete callback
response = arguments;
self.html( selector ?
// If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result
responseText );
// If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error"
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
}
return this;
};
// Attach a bunch of functions for handling common AJAX events
jQuery.each( [
"ajaxStart",
"ajaxStop",
"ajaxComplete",
"ajaxError",
"ajaxSuccess",
"ajaxSend"
], function( i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
} );
jQuery.expr.pseudos.animated = function( elem ) {
return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem;
} ).length;
};
jQuery.offset = {
setOffset: function( elem, options, i ) {
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
position = jQuery.css( elem, "position" ),
curElem = jQuery( elem ),
props = {};
// Set position first, in-case top/left are set even on static elem
if ( position === "static" ) {
elem.style.position = "relative";
}
curOffset = curElem.offset();
curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
// Need to be able to calculate position if either
// top or left is auto and position is either absolute or fixed
if ( calculatePosition ) {
curPosition = curElem.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
curTop = parseFloat( curCSSTop ) || 0;
curLeft = parseFloat( curCSSLeft ) || 0;
}
if ( isFunction( options ) ) {
// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
}
if ( options.top != null ) {
props.top = ( options.top - curOffset.top ) + curTop;
}
if ( options.left != null ) {
props.left = ( options.left - curOffset.left ) + curLeft;
}
if ( "using" in options ) {
options.using.call( elem, props );
} else {
curElem.css( props );
}
}
};
jQuery.fn.extend( {
// offset() relates an element's border box to the document origin
offset: function( options ) {
// Preserve chaining for setter
if ( arguments.length ) {
return options === undefined ?
this :
this.each( function( i ) {
jQuery.offset.setOffset( this, options, i );
} );
}
var rect, win,
elem = this[ 0 ];
if ( !elem ) {
return;
}
// Return zeros for disconnected and hidden (display: none) elements (gh-2310)
// Support: IE <=11 only
// Running getBoundingClientRect on a
// disconnected node in IE throws an error
if ( !elem.getClientRects().length ) {
return { top: 0, left: 0 };
}
// Get document-relative position by adding viewport scroll to viewport-relative gBCR
rect = elem.getBoundingClientRect();
win = elem.ownerDocument.defaultView;
return {
top: rect.top + win.pageYOffset,
left: rect.left + win.pageXOffset
};
},
// position() relates an element's margin box to its offset parent's padding box
// This corresponds to the behavior of CSS absolute positioning
position: function() {
if ( !this[ 0 ] ) {
return;
}
var offsetParent, offset, doc,
elem = this[ 0 ],
parentOffset = { top: 0, left: 0 };
// position:fixed elements are offset from the viewport, which itself always has zero offset
if ( jQuery.css( elem, "position" ) === "fixed" ) {
// Assume position:fixed implies availability of getBoundingClientRect
offset = elem.getBoundingClientRect();
} else {
offset = this.offset();
// Account for the *real* offset parent, which can be the document or its root element
// when a statically positioned element is identified
doc = elem.ownerDocument;
offsetParent = elem.offsetParent || doc.documentElement;
while ( offsetParent &&
( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
jQuery.css( offsetParent, "position" ) === "static" ) {
offsetParent = offsetParent.parentNode;
}
if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
// Incorporate borders into its offset, since they are outside its content origin
parentOffset = jQuery( offsetParent ).offset();
parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
}
}
// Subtract parent offsets and element margins
return {
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
};
},
// This method will return documentElement in the following cases:
// 1) For the element inside the iframe without offsetParent, this method will return
// documentElement of the parent window
// 2) For the hidden or detached element
// 3) For body or html element, i.e. in case of the html node - it will return itself
//
// but those exceptions were never presented as a real life use-cases
// and might be considered as more preferable results.
//
// This logic, however, is not guaranteed and can change at any point in the future
offsetParent: function() {
return this.map( function() {
var offsetParent = this.offsetParent;
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent || documentElement;
} );
}
} );
// Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
var top = "pageYOffset" === prop;
jQuery.fn[ method ] = function( val ) {
return access( this, function( elem, method, val ) {
// Coalesce documents and windows
var win;
if ( isWindow( elem ) ) {
win = elem;
} else if ( elem.nodeType === 9 ) {
win = elem.defaultView;
}
if ( val === undefined ) {
return win ? win[ prop ] : elem[ method ];
}
if ( win ) {
win.scrollTo(
!top ? val : win.pageXOffset,
top ? val : win.pageYOffset
);
} else {
elem[ method ] = val;
}
}, method, val, arguments.length );
};
} );
// Support: Safari <=7 - 9.1, Chrome <=37 - 49
// Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
// getComputedStyle returns percent when specified for top/left/bottom/right;
// rather than make the css module depend on the offset module, just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
function( elem, computed ) {
if ( computed ) {
computed = curCSS( elem, prop );
// If curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" :
computed;
}
}
);
} );
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) {
// Margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
return access( this, function( elem, type, value ) {
var doc;
if ( isWindow( elem ) ) {
// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
return funcName.indexOf( "outer" ) === 0 ?
elem[ "inner" + name ] :
elem.document.documentElement[ "client" + name ];
}
// Get document width or height
if ( elem.nodeType === 9 ) {
doc = elem.documentElement;
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
// whichever is greatest
return Math.max(
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
elem.body[ "offset" + name ], doc[ "offset" + name ],
doc[ "client" + name ]
);
}
return value === undefined ?
// Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) :
// Set width or height on the element
jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable );
};
} );
} );
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
} );
jQuery.fn.extend( {
hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
}
} );
jQuery.fn.extend( {
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
}
} );
// Bind a function to a context, optionally partially applying any
// arguments.
// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
// However, it is not slated for removal any time soon
jQuery.proxy = function( fn, context ) {
var tmp, args, proxy;
if ( typeof context === "string" ) {
tmp = fn[ context ];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( !isFunction( fn ) ) {
return undefined;
}
// Simulated bind
args = slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
};
jQuery.holdReady = function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
};
jQuery.isArray = Array.isArray;
jQuery.parseJSON = JSON.parse;
jQuery.nodeName = nodeName;
jQuery.isFunction = isFunction;
jQuery.isWindow = isWindow;
jQuery.camelCase = camelCase;
jQuery.type = toType;
jQuery.now = Date.now;
jQuery.isNumeric = function( obj ) {
// As of jQuery 3.0, isNumeric is limited to
// strings and numbers (primitives or objects)
// that can be coerced to finite numbers (gh-2662)
var type = jQuery.type( obj );
return ( type === "number" || type === "string" ) &&
// parseFloat NaNs numeric-cast false positives ("")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
!isNaN( obj - parseFloat( obj ) );
};
// Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust
// way to register. Lowercase jquery is used because AMD module names are
// derived from file names, and jQuery is normally delivered in a lowercase
// file name. Do this after creating the global so that if an AMD module wants
// to call noConflict to hide this version of jQuery, it will work.
// Note that for maximum portability, libraries that are not jQuery should
// declare themselves as anonymous modules, and avoid setting a global if an
// AMD loader is present. jQuery is a special case. For more information, see
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
if ( true ) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
return jQuery;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
var
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$;
jQuery.noConflict = function( deep ) {
if ( window.$ === jQuery ) {
window.$ = _$;
}
if ( deep && window.jQuery === jQuery ) {
window.jQuery = _jQuery;
}
return jQuery;
};
// Expose jQuery and $ identifiers, even in AMD
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
if ( !noGlobal ) {
window.jQuery = window.$ = jQuery;
}
return jQuery;
} );
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jquery___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jquery__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_bootstrap__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_bootstrap___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_bootstrap__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bootstrap_select__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_bootstrap_select___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_bootstrap_select__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bootstrap_validator__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bootstrap_validator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_bootstrap_validator__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bootstrap_fileinput__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bootstrap_fileinput___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_bootstrap_fileinput__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_bootstrap_dist_css_bootstrap_css__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_bootstrap_dist_css_bootstrap_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_bootstrap_dist_css_bootstrap_css__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_bootstrap_select_dist_css_bootstrap_select_css__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_bootstrap_select_dist_css_bootstrap_select_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_bootstrap_select_dist_css_bootstrap_select_css__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_bootstrap_fileinput_css_fileinput_css__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_bootstrap_fileinput_css_fileinput_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_bootstrap_fileinput_css_fileinput_css__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_css_all_css__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_css_all_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_css_all_css__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__style_css__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__style_css___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__style_css__);
// Javascript
// CSS
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(function () {
__WEBPACK_IMPORTED_MODULE_0_jquery___default()("#myInput").on("keyup", function(eventObject) {
var input, filter, ul, li, a, i;
input = eventObject.currentTarget;
filter = input.value.toUpperCase();
ul = document.getElementById("myUL");
li = ul.getElementsByTagName('a');
// Loop through all list items, and hide those who don't match the search query
for (i = 0; i < li.length; i++) {
a = li[i]; //li[i].getElementsByTagName("a")[0];
if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
});
function checkUsernameInputHandler(eventObject) {
var input_el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()(eventObject.currentTarget);
var data = JSON.stringify({"username": input_el.val()});
var url = `/teachers/check_username/${input_el.val()}`
__WEBPACK_IMPORTED_MODULE_0_jquery___default.a.post(
url,
data,
function(result) {
if (result.exists) {
console.log("Username exists");
}
},
"json"
);
}
function usernameGenerator(eventObject, firstname, surname) {
var input_el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()(eventObject.currentTarget);
input_el.val(firstname+"."+surname);
}
function deleteRelationHandler(eventObject) {
var url = this.dataset.url;
var modalEl = __WEBPACK_IMPORTED_MODULE_0_jquery___default()('#karmen-modal-remove');
var el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()(this);
modalEl.modal({backdrop: 'static'}).one('click', '#karmen-modal-btn-confirm', function() {
__WEBPACK_IMPORTED_MODULE_0_jquery___default.a.ajax({
url: url,
type: 'DELETE',
success: function(result) {
el.closest(".list-group-item").remove();
modalEl.modal('hide');
}
});
});
return false;
};
function deleteHandler(eventObject) {
var url = this.dataset.url;
var modalEl = __WEBPACK_IMPORTED_MODULE_0_jquery___default()('#karmen-modal-remove');
var el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()(this);
modalEl.modal({backdrop: 'static'}).one('click', '#karmen-modal-btn-confirm', function() {
__WEBPACK_IMPORTED_MODULE_0_jquery___default.a.ajax({
url: url,
type: 'DELETE',
success: function(result) {
modalEl.modal('hide');
window.location.replace(result.redirect_url);
}
});
});
return false;
};
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(".ajax-post").on("click", function(eventObject) {
var select_el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()("#"+this.dataset.select).first();
var listgroup_el = __WEBPACK_IMPORTED_MODULE_0_jquery___default()("#"+this.dataset.listgroup).first();
var url = this.dataset.url;
var data = JSON.stringify({"ids": select_el.val()});
__WEBPACK_IMPORTED_MODULE_0_jquery___default.a.post(
url,
data,
function(result) {
var i;
if (result.elements != null) {
for (i = 0; i < result.elements.length; i++) {
var newItem = `
<a href="#" class="list-group-item clearfix">
<span class="glyphicon glyphicon-book"></span>
${result.elements[i].Name}
<span class="pull-right">
<button data-url="/${result.name1}/${result.id1}/${result.name2}/${result.id2[i]}/delete" class="btn btn-xs btn-warning karmen-ajax-delete">
<span class="glyphicon glyphicon-trash"></span>
</button>
</span>
`;
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(listgroup_el).append(newItem);
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(".karmen-ajax-delete").on("click", deleteHandler);
}
}
},
"json"
);
select_el.val('default');
select_el.selectpicker("refresh");
return false;
});
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(".karmen-ajax-delete-relation").on("click", deleteRelationHandler);
__WEBPACK_IMPORTED_MODULE_0_jquery___default()(".karmen-ajax-delete").on("click", deleteHandler);
});
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/*!
* Bootstrap v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
(function (global, factory) {
true ? factory(exports, __webpack_require__(0), __webpack_require__(3)) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery', 'popper.js'], factory) :
(global = global || self, factory(global.bootstrap = {}, global.jQuery, global.Popper));
}(this, function (exports, $, Popper) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.3.1): util.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Private TransitionEnd Helpers
* ------------------------------------------------------------------------
*/
var TRANSITION_END = 'transitionend';
var MAX_UID = 1000000;
var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType(obj) {
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
}
function getSpecialTransitionEndEvent() {
return {
bindType: TRANSITION_END,
delegateType: TRANSITION_END,
handle: function handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
}
return undefined; // eslint-disable-line no-undefined
}
};
}
function transitionEndEmulator(duration) {
var _this = this;
var called = false;
$(this).one(Util.TRANSITION_END, function () {
called = true;
});
setTimeout(function () {
if (!called) {
Util.triggerTransitionEnd(_this);
}
}, duration);
return this;
}
function setTransitionEndSupport() {
$.fn.emulateTransitionEnd = transitionEndEmulator;
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
}
/**
* --------------------------------------------------------------------------
* Public Util Api
* --------------------------------------------------------------------------
*/
var Util = {
TRANSITION_END: 'bsTransitionEnd',
getUID: function getUID(prefix) {
do {
// eslint-disable-next-line no-bitwise
prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
} while (document.getElementById(prefix));
return prefix;
},
getSelectorFromElement: function getSelectorFromElement(element) {
var selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href');
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
}
try {
return document.querySelector(selector) ? selector : null;
} catch (err) {
return null;
}
},
getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
if (!element) {
return 0;
} // Get transition-duration of the element
var transitionDuration = $(element).css('transition-duration');
var transitionDelay = $(element).css('transition-delay');
var floatTransitionDuration = parseFloat(transitionDuration);
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
} // If multiple durations are defined, take the first
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
},
reflow: function reflow(element) {
return element.offsetHeight;
},
triggerTransitionEnd: function triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
return Boolean(TRANSITION_END);
},
isElement: function isElement(obj) {
return (obj[0] || obj).nodeType;
},
typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
for (var property in configTypes) {
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
var expectedTypes = configTypes[property];
var value = config[property];
var valueType = value && Util.isElement(value) ? 'element' : toType(value);
if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
}
}
}
},
findShadowRoot: function findShadowRoot(element) {
if (!document.documentElement.attachShadow) {
return null;
} // Can find the shadow root otherwise it'll return the document
if (typeof element.getRootNode === 'function') {
var root = element.getRootNode();
return root instanceof ShadowRoot ? root : null;
}
if (element instanceof ShadowRoot) {
return element;
} // when we don't find a shadow root
if (!element.parentNode) {
return null;
}
return Util.findShadowRoot(element.parentNode);
}
};
setTransitionEndSupport();
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'alert';
var VERSION = '4.3.1';
var DATA_KEY = 'bs.alert';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Selector = {
DISMISS: '[data-dismiss="alert"]'
};
var Event = {
CLOSE: "close" + EVENT_KEY,
CLOSED: "closed" + EVENT_KEY,
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
};
var ClassName = {
ALERT: 'alert',
FADE: 'fade',
SHOW: 'show'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Alert =
/*#__PURE__*/
function () {
function Alert(element) {
this._element = element;
} // Getters
var _proto = Alert.prototype;
// Public
_proto.close = function close(element) {
var rootElement = this._element;
if (element) {
rootElement = this._getRootElement(element);
}
var customEvent = this._triggerCloseEvent(rootElement);
if (customEvent.isDefaultPrevented()) {
return;
}
this._removeElement(rootElement);
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY);
this._element = null;
} // Private
;
_proto._getRootElement = function _getRootElement(element) {
var selector = Util.getSelectorFromElement(element);
var parent = false;
if (selector) {
parent = document.querySelector(selector);
}
if (!parent) {
parent = $(element).closest("." + ClassName.ALERT)[0];
}
return parent;
};
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
var closeEvent = $.Event(Event.CLOSE);
$(element).trigger(closeEvent);
return closeEvent;
};
_proto._removeElement = function _removeElement(element) {
var _this = this;
$(element).removeClass(ClassName.SHOW);
if (!$(element).hasClass(ClassName.FADE)) {
this._destroyElement(element);
return;
}
var transitionDuration = Util.getTransitionDurationFromElement(element);
$(element).one(Util.TRANSITION_END, function (event) {
return _this._destroyElement(element, event);
}).emulateTransitionEnd(transitionDuration);
};
_proto._destroyElement = function _destroyElement(element) {
$(element).detach().trigger(Event.CLOSED).remove();
} // Static
;
Alert._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var $element = $(this);
var data = $element.data(DATA_KEY);
if (!data) {
data = new Alert(this);
$element.data(DATA_KEY, data);
}
if (config === 'close') {
data[config](this);
}
});
};
Alert._handleDismiss = function _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault();
}
alertInstance.close(this);
};
};
_createClass(Alert, null, [{
key: "VERSION",
get: function get() {
return VERSION;
}
}]);
return Alert;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Alert._jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$1 = 'button';
var VERSION$1 = '4.3.1';
var DATA_KEY$1 = 'bs.button';
var EVENT_KEY$1 = "." + DATA_KEY$1;
var DATA_API_KEY$1 = '.data-api';
var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
var ClassName$1 = {
ACTIVE: 'active',
BUTTON: 'btn',
FOCUS: 'focus'
};
var Selector$1 = {
DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
DATA_TOGGLE: '[data-toggle="buttons"]',
INPUT: 'input:not([type="hidden"])',
ACTIVE: '.active',
BUTTON: '.btn'
};
var Event$1 = {
CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1)
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Button =
/*#__PURE__*/
function () {
function Button(element) {
this._element = element;
} // Getters
var _proto = Button.prototype;
// Public
_proto.toggle = function toggle() {
var triggerChangeEvent = true;
var addAriaPressed = true;
var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLE)[0];
if (rootElement) {
var input = this._element.querySelector(Selector$1.INPUT);
if (input) {
if (input.type === 'radio') {
if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
triggerChangeEvent = false;
} else {
var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
if (activeElement) {
$(activeElement).removeClass(ClassName$1.ACTIVE);
}
}
}
if (triggerChangeEvent) {
if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
return;
}
input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
$(input).trigger('change');
}
input.focus();
addAriaPressed = false;
}
}
if (addAriaPressed) {
this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
}
if (triggerChangeEvent) {
$(this._element).toggleClass(ClassName$1.ACTIVE);
}
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY$1);
this._element = null;
} // Static
;
Button._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$1);
if (!data) {
data = new Button(this);
$(this).data(DATA_KEY$1, data);
}
if (config === 'toggle') {
data[config]();
}
});
};
_createClass(Button, null, [{
key: "VERSION",
get: function get() {
return VERSION$1;
}
}]);
return Button;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
event.preventDefault();
var button = event.target;
if (!$(button).hasClass(ClassName$1.BUTTON)) {
button = $(button).closest(Selector$1.BUTTON);
}
Button._jQueryInterface.call($(button), 'toggle');
}).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
var button = $(event.target).closest(Selector$1.BUTTON)[0];
$(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$1] = Button._jQueryInterface;
$.fn[NAME$1].Constructor = Button;
$.fn[NAME$1].noConflict = function () {
$.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
return Button._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$2 = 'carousel';
var VERSION$2 = '4.3.1';
var DATA_KEY$2 = 'bs.carousel';
var EVENT_KEY$2 = "." + DATA_KEY$2;
var DATA_API_KEY$2 = '.data-api';
var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
var SWIPE_THRESHOLD = 40;
var Default = {
interval: 5000,
keyboard: true,
slide: false,
pause: 'hover',
wrap: true,
touch: true
};
var DefaultType = {
interval: '(number|boolean)',
keyboard: 'boolean',
slide: '(boolean|string)',
pause: '(string|boolean)',
wrap: 'boolean',
touch: 'boolean'
};
var Direction = {
NEXT: 'next',
PREV: 'prev',
LEFT: 'left',
RIGHT: 'right'
};
var Event$2 = {
SLIDE: "slide" + EVENT_KEY$2,
SLID: "slid" + EVENT_KEY$2,
KEYDOWN: "keydown" + EVENT_KEY$2,
MOUSEENTER: "mouseenter" + EVENT_KEY$2,
MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
TOUCHSTART: "touchstart" + EVENT_KEY$2,
TOUCHMOVE: "touchmove" + EVENT_KEY$2,
TOUCHEND: "touchend" + EVENT_KEY$2,
POINTERDOWN: "pointerdown" + EVENT_KEY$2,
POINTERUP: "pointerup" + EVENT_KEY$2,
DRAG_START: "dragstart" + EVENT_KEY$2,
LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
};
var ClassName$2 = {
CAROUSEL: 'carousel',
ACTIVE: 'active',
SLIDE: 'slide',
RIGHT: 'carousel-item-right',
LEFT: 'carousel-item-left',
NEXT: 'carousel-item-next',
PREV: 'carousel-item-prev',
ITEM: 'carousel-item',
POINTER_EVENT: 'pointer-event'
};
var Selector$2 = {
ACTIVE: '.active',
ACTIVE_ITEM: '.active.carousel-item',
ITEM: '.carousel-item',
ITEM_IMG: '.carousel-item img',
NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
INDICATORS: '.carousel-indicators',
DATA_SLIDE: '[data-slide], [data-slide-to]',
DATA_RIDE: '[data-ride="carousel"]'
};
var PointerType = {
TOUCH: 'touch',
PEN: 'pen'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Carousel =
/*#__PURE__*/
function () {
function Carousel(element, config) {
this._items = null;
this._interval = null;
this._activeElement = null;
this._isPaused = false;
this._isSliding = false;
this.touchTimeout = null;
this.touchStartX = 0;
this.touchDeltaX = 0;
this._config = this._getConfig(config);
this._element = element;
this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
this._addEventListeners();
} // Getters
var _proto = Carousel.prototype;
// Public
_proto.next = function next() {
if (!this._isSliding) {
this._slide(Direction.NEXT);
}
};
_proto.nextWhenVisible = function nextWhenVisible() {
// Don't call next when the page isn't visible
// or the carousel or its parent isn't visible
if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
this.next();
}
};
_proto.prev = function prev() {
if (!this._isSliding) {
this._slide(Direction.PREV);
}
};
_proto.pause = function pause(event) {
if (!event) {
this._isPaused = true;
}
if (this._element.querySelector(Selector$2.NEXT_PREV)) {
Util.triggerTransitionEnd(this._element);
this.cycle(true);
}
clearInterval(this._interval);
this._interval = null;
};
_proto.cycle = function cycle(event) {
if (!event) {
this._isPaused = false;
}
if (this._interval) {
clearInterval(this._interval);
this._interval = null;
}
if (this._config.interval && !this._isPaused) {
this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
}
};
_proto.to = function to(index) {
var _this = this;
this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
var activeIndex = this._getItemIndex(this._activeElement);
if (index > this._items.length - 1 || index < 0) {
return;
}
if (this._isSliding) {
$(this._element).one(Event$2.SLID, function () {
return _this.to(index);
});
return;
}
if (activeIndex === index) {
this.pause();
this.cycle();
return;
}
var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
this._slide(direction, this._items[index]);
};
_proto.dispose = function dispose() {
$(this._element).off(EVENT_KEY$2);
$.removeData(this._element, DATA_KEY$2);
this._items = null;
this._config = null;
this._element = null;
this._interval = null;
this._isPaused = null;
this._isSliding = null;
this._activeElement = null;
this._indicatorsElement = null;
} // Private
;
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, Default, config);
Util.typeCheckConfig(NAME$2, config, DefaultType);
return config;
};
_proto._handleSwipe = function _handleSwipe() {
var absDeltax = Math.abs(this.touchDeltaX);
if (absDeltax <= SWIPE_THRESHOLD) {
return;
}
var direction = absDeltax / this.touchDeltaX; // swipe left
if (direction > 0) {
this.prev();
} // swipe right
if (direction < 0) {
this.next();
}
};
_proto._addEventListeners = function _addEventListeners() {
var _this2 = this;
if (this._config.keyboard) {
$(this._element).on(Event$2.KEYDOWN, function (event) {
return _this2._keydown(event);
});
}
if (this._config.pause === 'hover') {
$(this._element).on(Event$2.MOUSEENTER, function (event) {
return _this2.pause(event);
}).on(Event$2.MOUSELEAVE, function (event) {
return _this2.cycle(event);
});
}
if (this._config.touch) {
this._addTouchEventListeners();
}
};
_proto._addTouchEventListeners = function _addTouchEventListeners() {
var _this3 = this;
if (!this._touchSupported) {
return;
}
var start = function start(event) {
if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
_this3.touchStartX = event.originalEvent.clientX;
} else if (!_this3._pointerEvent) {
_this3.touchStartX = event.originalEvent.touches[0].clientX;
}
};
var move = function move(event) {
// ensure swiping with one touch and not pinching
if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
_this3.touchDeltaX = 0;
} else {
_this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
}
};
var end = function end(event) {
if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
_this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
}
_this3._handleSwipe();
if (_this3._config.pause === 'hover') {
// If it's a touch-enabled device, mouseenter/leave are fired as
// part of the mouse compatibility events on first tap - the carousel
// would stop cycling until user tapped out of it;
// here, we listen for touchend, explicitly pause the carousel
// (as if it's the second time we tap on it, mouseenter compat event
// is NOT fired) and after a timeout (to allow for mouse compatibility
// events to fire) we explicitly restart cycling
_this3.pause();
if (_this3.touchTimeout) {
clearTimeout(_this3.touchTimeout);
}
_this3.touchTimeout = setTimeout(function (event) {
return _this3.cycle(event);
}, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
}
};
$(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
return e.preventDefault();
});
if (this._pointerEvent) {
$(this._element).on(Event$2.POINTERDOWN, function (event) {
return start(event);
});
$(this._element).on(Event$2.POINTERUP, function (event) {
return end(event);
});
this._element.classList.add(ClassName$2.POINTER_EVENT);
} else {
$(this._element).on(Event$2.TOUCHSTART, function (event) {
return start(event);
});
$(this._element).on(Event$2.TOUCHMOVE, function (event) {
return move(event);
});
$(this._element).on(Event$2.TOUCHEND, function (event) {
return end(event);
});
}
};
_proto._keydown = function _keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) {
return;
}
switch (event.which) {
case ARROW_LEFT_KEYCODE:
event.preventDefault();
this.prev();
break;
case ARROW_RIGHT_KEYCODE:
event.preventDefault();
this.next();
break;
default:
}
};
_proto._getItemIndex = function _getItemIndex(element) {
this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
return this._items.indexOf(element);
};
_proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
var isNextDirection = direction === Direction.NEXT;
var isPrevDirection = direction === Direction.PREV;
var activeIndex = this._getItemIndex(activeElement);
var lastItemIndex = this._items.length - 1;
var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
if (isGoingToWrap && !this._config.wrap) {
return activeElement;
}
var delta = direction === Direction.PREV ? -1 : 1;
var itemIndex = (activeIndex + delta) % this._items.length;
return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
};
_proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
var targetIndex = this._getItemIndex(relatedTarget);
var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
var slideEvent = $.Event(Event$2.SLIDE, {
relatedTarget: relatedTarget,
direction: eventDirectionName,
from: fromIndex,
to: targetIndex
});
$(this._element).trigger(slideEvent);
return slideEvent;
};
_proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
if (this._indicatorsElement) {
var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
$(indicators).removeClass(ClassName$2.ACTIVE);
var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
if (nextIndicator) {
$(nextIndicator).addClass(ClassName$2.ACTIVE);
}
}
};
_proto._slide = function _slide(direction, element) {
var _this4 = this;
var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
var activeElementIndex = this._getItemIndex(activeElement);
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
var nextElementIndex = this._getItemIndex(nextElement);
var isCycling = Boolean(this._interval);
var directionalClassName;
var orderClassName;
var eventDirectionName;
if (direction === Direction.NEXT) {
directionalClassName = ClassName$2.LEFT;
orderClassName = ClassName$2.NEXT;
eventDirectionName = Direction.LEFT;
} else {
directionalClassName = ClassName$2.RIGHT;
orderClassName = ClassName$2.PREV;
eventDirectionName = Direction.RIGHT;
}
if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
this._isSliding = false;
return;
}
var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
if (slideEvent.isDefaultPrevented()) {
return;
}
if (!activeElement || !nextElement) {
// Some weirdness is happening, so we bail
return;
}
this._isSliding = true;
if (isCycling) {
this.pause();
}
this._setActiveIndicatorElement(nextElement);
var slidEvent = $.Event(Event$2.SLID, {
relatedTarget: nextElement,
direction: eventDirectionName,
from: activeElementIndex,
to: nextElementIndex
});
if ($(this._element).hasClass(ClassName$2.SLIDE)) {
$(nextElement).addClass(orderClassName);
Util.reflow(nextElement);
$(activeElement).addClass(directionalClassName);
$(nextElement).addClass(directionalClassName);
var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
if (nextElementInterval) {
this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
this._config.interval = nextElementInterval;
} else {
this._config.interval = this._config.defaultInterval || this._config.interval;
}
var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
$(activeElement).one(Util.TRANSITION_END, function () {
$(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
$(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
_this4._isSliding = false;
setTimeout(function () {
return $(_this4._element).trigger(slidEvent);
}, 0);
}).emulateTransitionEnd(transitionDuration);
} else {
$(activeElement).removeClass(ClassName$2.ACTIVE);
$(nextElement).addClass(ClassName$2.ACTIVE);
this._isSliding = false;
$(this._element).trigger(slidEvent);
}
if (isCycling) {
this.cycle();
}
} // Static
;
Carousel._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$2);
var _config = _objectSpread({}, Default, $(this).data());
if (typeof config === 'object') {
_config = _objectSpread({}, _config, config);
}
var action = typeof config === 'string' ? config : _config.slide;
if (!data) {
data = new Carousel(this, _config);
$(this).data(DATA_KEY$2, data);
}
if (typeof config === 'number') {
data.to(config);
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new TypeError("No method named \"" + action + "\"");
}
data[action]();
} else if (_config.interval && _config.ride) {
data.pause();
data.cycle();
}
});
};
Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
var selector = Util.getSelectorFromElement(this);
if (!selector) {
return;
}
var target = $(selector)[0];
if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
return;
}
var config = _objectSpread({}, $(target).data(), $(this).data());
var slideIndex = this.getAttribute('data-slide-to');
if (slideIndex) {
config.interval = false;
}
Carousel._jQueryInterface.call($(target), config);
if (slideIndex) {
$(target).data(DATA_KEY$2).to(slideIndex);
}
event.preventDefault();
};
_createClass(Carousel, null, [{
key: "VERSION",
get: function get() {
return VERSION$2;
}
}, {
key: "Default",
get: function get() {
return Default;
}
}]);
return Carousel;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
$(window).on(Event$2.LOAD_DATA_API, function () {
var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
for (var i = 0, len = carousels.length; i < len; i++) {
var $carousel = $(carousels[i]);
Carousel._jQueryInterface.call($carousel, $carousel.data());
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$2] = Carousel._jQueryInterface;
$.fn[NAME$2].Constructor = Carousel;
$.fn[NAME$2].noConflict = function () {
$.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
return Carousel._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$3 = 'collapse';
var VERSION$3 = '4.3.1';
var DATA_KEY$3 = 'bs.collapse';
var EVENT_KEY$3 = "." + DATA_KEY$3;
var DATA_API_KEY$3 = '.data-api';
var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
var Default$1 = {
toggle: true,
parent: ''
};
var DefaultType$1 = {
toggle: 'boolean',
parent: '(string|element)'
};
var Event$3 = {
SHOW: "show" + EVENT_KEY$3,
SHOWN: "shown" + EVENT_KEY$3,
HIDE: "hide" + EVENT_KEY$3,
HIDDEN: "hidden" + EVENT_KEY$3,
CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
};
var ClassName$3 = {
SHOW: 'show',
COLLAPSE: 'collapse',
COLLAPSING: 'collapsing',
COLLAPSED: 'collapsed'
};
var Dimension = {
WIDTH: 'width',
HEIGHT: 'height'
};
var Selector$3 = {
ACTIVES: '.show, .collapsing',
DATA_TOGGLE: '[data-toggle="collapse"]'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Collapse =
/*#__PURE__*/
function () {
function Collapse(element, config) {
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
for (var i = 0, len = toggleList.length; i < len; i++) {
var elem = toggleList[i];
var selector = Util.getSelectorFromElement(elem);
var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
return foundElem === element;
});
if (selector !== null && filterElement.length > 0) {
this._selector = selector;
this._triggerArray.push(elem);
}
}
this._parent = this._config.parent ? this._getParent() : null;
if (!this._config.parent) {
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
}
if (this._config.toggle) {
this.toggle();
}
} // Getters
var _proto = Collapse.prototype;
// Public
_proto.toggle = function toggle() {
if ($(this._element).hasClass(ClassName$3.SHOW)) {
this.hide();
} else {
this.show();
}
};
_proto.show = function show() {
var _this = this;
if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
return;
}
var actives;
var activesData;
if (this._parent) {
actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
if (typeof _this._config.parent === 'string') {
return elem.getAttribute('data-parent') === _this._config.parent;
}
return elem.classList.contains(ClassName$3.COLLAPSE);
});
if (actives.length === 0) {
actives = null;
}
}
if (actives) {
activesData = $(actives).not(this._selector).data(DATA_KEY$3);
if (activesData && activesData._isTransitioning) {
return;
}
}
var startEvent = $.Event(Event$3.SHOW);
$(this._element).trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return;
}
if (actives) {
Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
if (!activesData) {
$(actives).data(DATA_KEY$3, null);
}
}
var dimension = this._getDimension();
$(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
this._element.style[dimension] = 0;
if (this._triggerArray.length) {
$(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
}
this.setTransitioning(true);
var complete = function complete() {
$(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
_this._element.style[dimension] = '';
_this.setTransitioning(false);
$(_this._element).trigger(Event$3.SHOWN);
};
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
var scrollSize = "scroll" + capitalizedDimension;
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
this._element.style[dimension] = this._element[scrollSize] + "px";
};
_proto.hide = function hide() {
var _this2 = this;
if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
return;
}
var startEvent = $.Event(Event$3.HIDE);
$(this._element).trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return;
}
var dimension = this._getDimension();
this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
Util.reflow(this._element);
$(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
var triggerArrayLength = this._triggerArray.length;
if (triggerArrayLength > 0) {
for (var i = 0; i < triggerArrayLength; i++) {
var trigger = this._triggerArray[i];
var selector = Util.getSelectorFromElement(trigger);
if (selector !== null) {
var $elem = $([].slice.call(document.querySelectorAll(selector)));
if (!$elem.hasClass(ClassName$3.SHOW)) {
$(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
}
}
}
}
this.setTransitioning(true);
var complete = function complete() {
_this2.setTransitioning(false);
$(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
};
this._element.style[dimension] = '';
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
};
_proto.setTransitioning = function setTransitioning(isTransitioning) {
this._isTransitioning = isTransitioning;
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY$3);
this._config = null;
this._parent = null;
this._element = null;
this._triggerArray = null;
this._isTransitioning = null;
} // Private
;
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, Default$1, config);
config.toggle = Boolean(config.toggle); // Coerce string values
Util.typeCheckConfig(NAME$3, config, DefaultType$1);
return config;
};
_proto._getDimension = function _getDimension() {
var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
};
_proto._getParent = function _getParent() {
var _this3 = this;
var parent;
if (Util.isElement(this._config.parent)) {
parent = this._config.parent; // It's a jQuery object
if (typeof this._config.parent.jquery !== 'undefined') {
parent = this._config.parent[0];
}
} else {
parent = document.querySelector(this._config.parent);
}
var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
var children = [].slice.call(parent.querySelectorAll(selector));
$(children).each(function (i, element) {
_this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
});
return parent;
};
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
var isOpen = $(element).hasClass(ClassName$3.SHOW);
if (triggerArray.length) {
$(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
}
} // Static
;
Collapse._getTargetFromElement = function _getTargetFromElement(element) {
var selector = Util.getSelectorFromElement(element);
return selector ? document.querySelector(selector) : null;
};
Collapse._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DATA_KEY$3);
var _config = _objectSpread({}, Default$1, $this.data(), typeof config === 'object' && config ? config : {});
if (!data && _config.toggle && /show|hide/.test(config)) {
_config.toggle = false;
}
if (!data) {
data = new Collapse(this, _config);
$this.data(DATA_KEY$3, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
_createClass(Collapse, null, [{
key: "VERSION",
get: function get() {
return VERSION$3;
}
}, {
key: "Default",
get: function get() {
return Default$1;
}
}]);
return Collapse;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
if (event.currentTarget.tagName === 'A') {
event.preventDefault();
}
var $trigger = $(this);
var selector = Util.getSelectorFromElement(this);
var selectors = [].slice.call(document.querySelectorAll(selector));
$(selectors).each(function () {
var $target = $(this);
var data = $target.data(DATA_KEY$3);
var config = data ? 'toggle' : $trigger.data();
Collapse._jQueryInterface.call($target, config);
});
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$3] = Collapse._jQueryInterface;
$.fn[NAME$3].Constructor = Collapse;
$.fn[NAME$3].noConflict = function () {
$.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
return Collapse._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$4 = 'dropdown';
var VERSION$4 = '4.3.1';
var DATA_KEY$4 = 'bs.dropdown';
var EVENT_KEY$4 = "." + DATA_KEY$4;
var DATA_API_KEY$4 = '.data-api';
var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
var Event$4 = {
HIDE: "hide" + EVENT_KEY$4,
HIDDEN: "hidden" + EVENT_KEY$4,
SHOW: "show" + EVENT_KEY$4,
SHOWN: "shown" + EVENT_KEY$4,
CLICK: "click" + EVENT_KEY$4,
CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
};
var ClassName$4 = {
DISABLED: 'disabled',
SHOW: 'show',
DROPUP: 'dropup',
DROPRIGHT: 'dropright',
DROPLEFT: 'dropleft',
MENURIGHT: 'dropdown-menu-right',
MENULEFT: 'dropdown-menu-left',
POSITION_STATIC: 'position-static'
};
var Selector$4 = {
DATA_TOGGLE: '[data-toggle="dropdown"]',
FORM_CHILD: '.dropdown form',
MENU: '.dropdown-menu',
NAVBAR_NAV: '.navbar-nav',
VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
};
var AttachmentMap = {
TOP: 'top-start',
TOPEND: 'top-end',
BOTTOM: 'bottom-start',
BOTTOMEND: 'bottom-end',
RIGHT: 'right-start',
RIGHTEND: 'right-end',
LEFT: 'left-start',
LEFTEND: 'left-end'
};
var Default$2 = {
offset: 0,
flip: true,
boundary: 'scrollParent',
reference: 'toggle',
display: 'dynamic'
};
var DefaultType$2 = {
offset: '(number|string|function)',
flip: 'boolean',
boundary: '(string|element)',
reference: '(string|element)',
display: 'string'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Dropdown =
/*#__PURE__*/
function () {
function Dropdown(element, config) {
this._element = element;
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
this._inNavbar = this._detectNavbar();
this._addEventListeners();
} // Getters
var _proto = Dropdown.prototype;
// Public
_proto.toggle = function toggle() {
if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
return;
}
var parent = Dropdown._getParentFromElement(this._element);
var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
Dropdown._clearMenus();
if (isActive) {
return;
}
var relatedTarget = {
relatedTarget: this._element
};
var showEvent = $.Event(Event$4.SHOW, relatedTarget);
$(parent).trigger(showEvent);
if (showEvent.isDefaultPrevented()) {
return;
} // Disable totally Popper.js for Dropdown in Navbar
if (!this._inNavbar) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
}
var referenceElement = this._element;
if (this._config.reference === 'parent') {
referenceElement = parent;
} else if (Util.isElement(this._config.reference)) {
referenceElement = this._config.reference; // Check if it's jQuery element
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
} // If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
// https://github.com/twbs/bootstrap/issues/24251
if (this._config.boundary !== 'scrollParent') {
$(parent).addClass(ClassName$4.POSITION_STATIC);
}
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
} // If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
$(document.body).children().on('mouseover', null, $.noop);
}
this._element.focus();
this._element.setAttribute('aria-expanded', true);
$(this._menu).toggleClass(ClassName$4.SHOW);
$(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
};
_proto.show = function show() {
if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
return;
}
var relatedTarget = {
relatedTarget: this._element
};
var showEvent = $.Event(Event$4.SHOW, relatedTarget);
var parent = Dropdown._getParentFromElement(this._element);
$(parent).trigger(showEvent);
if (showEvent.isDefaultPrevented()) {
return;
}
$(this._menu).toggleClass(ClassName$4.SHOW);
$(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
};
_proto.hide = function hide() {
if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
return;
}
var relatedTarget = {
relatedTarget: this._element
};
var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
var parent = Dropdown._getParentFromElement(this._element);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
return;
}
$(this._menu).toggleClass(ClassName$4.SHOW);
$(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY$4);
$(this._element).off(EVENT_KEY$4);
this._element = null;
this._menu = null;
if (this._popper !== null) {
this._popper.destroy();
this._popper = null;
}
};
_proto.update = function update() {
this._inNavbar = this._detectNavbar();
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
} // Private
;
_proto._addEventListeners = function _addEventListeners() {
var _this = this;
$(this._element).on(Event$4.CLICK, function (event) {
event.preventDefault();
event.stopPropagation();
_this.toggle();
});
};
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config);
Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
return config;
};
_proto._getMenuElement = function _getMenuElement() {
if (!this._menu) {
var parent = Dropdown._getParentFromElement(this._element);
if (parent) {
this._menu = parent.querySelector(Selector$4.MENU);
}
}
return this._menu;
};
_proto._getPlacement = function _getPlacement() {
var $parentDropdown = $(this._element.parentNode);
var placement = AttachmentMap.BOTTOM; // Handle dropup
if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
placement = AttachmentMap.TOP;
if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
placement = AttachmentMap.TOPEND;
}
} else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
placement = AttachmentMap.RIGHT;
} else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
placement = AttachmentMap.LEFT;
} else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
placement = AttachmentMap.BOTTOMEND;
}
return placement;
};
_proto._detectNavbar = function _detectNavbar() {
return $(this._element).closest('.navbar').length > 0;
};
_proto._getOffset = function _getOffset() {
var _this2 = this;
var offset = {};
if (typeof this._config.offset === 'function') {
offset.fn = function (data) {
data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
return data;
};
} else {
offset.offset = this._config.offset;
}
return offset;
};
_proto._getPopperConfig = function _getPopperConfig() {
var popperConfig = {
placement: this._getPlacement(),
modifiers: {
offset: this._getOffset(),
flip: {
enabled: this._config.flip
},
preventOverflow: {
boundariesElement: this._config.boundary
}
} // Disable Popper.js if we have a static display
};
if (this._config.display === 'static') {
popperConfig.modifiers.applyStyle = {
enabled: false
};
}
return popperConfig;
} // Static
;
Dropdown._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$4);
var _config = typeof config === 'object' ? config : null;
if (!data) {
data = new Dropdown(this, _config);
$(this).data(DATA_KEY$4, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
Dropdown._clearMenus = function _clearMenus(event) {
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
return;
}
var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
for (var i = 0, len = toggles.length; i < len; i++) {
var parent = Dropdown._getParentFromElement(toggles[i]);
var context = $(toggles[i]).data(DATA_KEY$4);
var relatedTarget = {
relatedTarget: toggles[i]
};
if (event && event.type === 'click') {
relatedTarget.clickEvent = event;
}
if (!context) {
continue;
}
var dropdownMenu = context._menu;
if (!$(parent).hasClass(ClassName$4.SHOW)) {
continue;
}
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
continue;
}
var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
continue;
} // If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$(document.body).children().off('mouseover', null, $.noop);
}
toggles[i].setAttribute('aria-expanded', 'false');
$(dropdownMenu).removeClass(ClassName$4.SHOW);
$(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
}
};
Dropdown._getParentFromElement = function _getParentFromElement(element) {
var parent;
var selector = Util.getSelectorFromElement(element);
if (selector) {
parent = document.querySelector(selector);
}
return parent || element.parentNode;
} // eslint-disable-next-line complexity
;
Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
// If not input/textarea:
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea:
// - If space key => not a dropdown command
// - If key is other than escape
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
return;
}
event.preventDefault();
event.stopPropagation();
if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
return;
}
var parent = Dropdown._getParentFromElement(this);
var isActive = $(parent).hasClass(ClassName$4.SHOW);
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
$(toggle).trigger('focus');
}
$(this).trigger('click');
return;
}
var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS));
if (items.length === 0) {
return;
}
var index = items.indexOf(event.target);
if (event.which === ARROW_UP_KEYCODE && index > 0) {
// Up
index--;
}
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
// Down
index++;
}
if (index < 0) {
index = 0;
}
items[index].focus();
};
_createClass(Dropdown, null, [{
key: "VERSION",
get: function get() {
return VERSION$4;
}
}, {
key: "Default",
get: function get() {
return Default$2;
}
}, {
key: "DefaultType",
get: function get() {
return DefaultType$2;
}
}]);
return Dropdown;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown._jQueryInterface.call($(this), 'toggle');
}).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
e.stopPropagation();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$4] = Dropdown._jQueryInterface;
$.fn[NAME$4].Constructor = Dropdown;
$.fn[NAME$4].noConflict = function () {
$.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
return Dropdown._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$5 = 'modal';
var VERSION$5 = '4.3.1';
var DATA_KEY$5 = 'bs.modal';
var EVENT_KEY$5 = "." + DATA_KEY$5;
var DATA_API_KEY$5 = '.data-api';
var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
var Default$3 = {
backdrop: true,
keyboard: true,
focus: true,
show: true
};
var DefaultType$3 = {
backdrop: '(boolean|string)',
keyboard: 'boolean',
focus: 'boolean',
show: 'boolean'
};
var Event$5 = {
HIDE: "hide" + EVENT_KEY$5,
HIDDEN: "hidden" + EVENT_KEY$5,
SHOW: "show" + EVENT_KEY$5,
SHOWN: "shown" + EVENT_KEY$5,
FOCUSIN: "focusin" + EVENT_KEY$5,
RESIZE: "resize" + EVENT_KEY$5,
CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
};
var ClassName$5 = {
SCROLLABLE: 'modal-dialog-scrollable',
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
BACKDROP: 'modal-backdrop',
OPEN: 'modal-open',
FADE: 'fade',
SHOW: 'show'
};
var Selector$5 = {
DIALOG: '.modal-dialog',
MODAL_BODY: '.modal-body',
DATA_TOGGLE: '[data-toggle="modal"]',
DATA_DISMISS: '[data-dismiss="modal"]',
FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
STICKY_CONTENT: '.sticky-top'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Modal =
/*#__PURE__*/
function () {
function Modal(element, config) {
this._config = this._getConfig(config);
this._element = element;
this._dialog = element.querySelector(Selector$5.DIALOG);
this._backdrop = null;
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollbarWidth = 0;
} // Getters
var _proto = Modal.prototype;
// Public
_proto.toggle = function toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget);
};
_proto.show = function show(relatedTarget) {
var _this = this;
if (this._isShown || this._isTransitioning) {
return;
}
if ($(this._element).hasClass(ClassName$5.FADE)) {
this._isTransitioning = true;
}
var showEvent = $.Event(Event$5.SHOW, {
relatedTarget: relatedTarget
});
$(this._element).trigger(showEvent);
if (this._isShown || showEvent.isDefaultPrevented()) {
return;
}
this._isShown = true;
this._checkScrollbar();
this._setScrollbar();
this._adjustDialog();
this._setEscapeEvent();
this._setResizeEvent();
$(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
return _this.hide(event);
});
$(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
$(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
if ($(event.target).is(_this._element)) {
_this._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(function () {
return _this._showElement(relatedTarget);
});
};
_proto.hide = function hide(event) {
var _this2 = this;
if (event) {
event.preventDefault();
}
if (!this._isShown || this._isTransitioning) {
return;
}
var hideEvent = $.Event(Event$5.HIDE);
$(this._element).trigger(hideEvent);
if (!this._isShown || hideEvent.isDefaultPrevented()) {
return;
}
this._isShown = false;
var transition = $(this._element).hasClass(ClassName$5.FADE);
if (transition) {
this._isTransitioning = true;
}
this._setEscapeEvent();
this._setResizeEvent();
$(document).off(Event$5.FOCUSIN);
$(this._element).removeClass(ClassName$5.SHOW);
$(this._element).off(Event$5.CLICK_DISMISS);
$(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
if (transition) {
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element).one(Util.TRANSITION_END, function (event) {
return _this2._hideModal(event);
}).emulateTransitionEnd(transitionDuration);
} else {
this._hideModal();
}
};
_proto.dispose = function dispose() {
[window, this._element, this._dialog].forEach(function (htmlElement) {
return $(htmlElement).off(EVENT_KEY$5);
});
/**
* `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
* Do not move `document` in `htmlElements` array
* It will remove `Event.CLICK_DATA_API` event that should remain
*/
$(document).off(Event$5.FOCUSIN);
$.removeData(this._element, DATA_KEY$5);
this._config = null;
this._element = null;
this._dialog = null;
this._backdrop = null;
this._isShown = null;
this._isBodyOverflowing = null;
this._ignoreBackdropClick = null;
this._isTransitioning = null;
this._scrollbarWidth = null;
};
_proto.handleUpdate = function handleUpdate() {
this._adjustDialog();
} // Private
;
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, Default$3, config);
Util.typeCheckConfig(NAME$5, config, DefaultType$3);
return config;
};
_proto._showElement = function _showElement(relatedTarget) {
var _this3 = this;
var transition = $(this._element).hasClass(ClassName$5.FADE);
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// Don't move modal's DOM position
document.body.appendChild(this._element);
}
this._element.style.display = 'block';
this._element.removeAttribute('aria-hidden');
this._element.setAttribute('aria-modal', true);
if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) {
this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0;
} else {
this._element.scrollTop = 0;
}
if (transition) {
Util.reflow(this._element);
}
$(this._element).addClass(ClassName$5.SHOW);
if (this._config.focus) {
this._enforceFocus();
}
var shownEvent = $.Event(Event$5.SHOWN, {
relatedTarget: relatedTarget
});
var transitionComplete = function transitionComplete() {
if (_this3._config.focus) {
_this3._element.focus();
}
_this3._isTransitioning = false;
$(_this3._element).trigger(shownEvent);
};
if (transition) {
var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
$(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
} else {
transitionComplete();
}
};
_proto._enforceFocus = function _enforceFocus() {
var _this4 = this;
$(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
.on(Event$5.FOCUSIN, function (event) {
if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) {
_this4._element.focus();
}
});
};
_proto._setEscapeEvent = function _setEscapeEvent() {
var _this5 = this;
if (this._isShown && this._config.keyboard) {
$(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
if (event.which === ESCAPE_KEYCODE$1) {
event.preventDefault();
_this5.hide();
}
});
} else if (!this._isShown) {
$(this._element).off(Event$5.KEYDOWN_DISMISS);
}
};
_proto._setResizeEvent = function _setResizeEvent() {
var _this6 = this;
if (this._isShown) {
$(window).on(Event$5.RESIZE, function (event) {
return _this6.handleUpdate(event);
});
} else {
$(window).off(Event$5.RESIZE);
}
};
_proto._hideModal = function _hideModal() {
var _this7 = this;
this._element.style.display = 'none';
this._element.setAttribute('aria-hidden', true);
this._element.removeAttribute('aria-modal');
this._isTransitioning = false;
this._showBackdrop(function () {
$(document.body).removeClass(ClassName$5.OPEN);
_this7._resetAdjustments();
_this7._resetScrollbar();
$(_this7._element).trigger(Event$5.HIDDEN);
});
};
_proto._removeBackdrop = function _removeBackdrop() {
if (this._backdrop) {
$(this._backdrop).remove();
this._backdrop = null;
}
};
_proto._showBackdrop = function _showBackdrop(callback) {
var _this8 = this;
var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
if (this._isShown && this._config.backdrop) {
this._backdrop = document.createElement('div');
this._backdrop.className = ClassName$5.BACKDROP;
if (animate) {
this._backdrop.classList.add(animate);
}
$(this._backdrop).appendTo(document.body);
$(this._element).on(Event$5.CLICK_DISMISS, function (event) {
if (_this8._ignoreBackdropClick) {
_this8._ignoreBackdropClick = false;
return;
}
if (event.target !== event.currentTarget) {
return;
}
if (_this8._config.backdrop === 'static') {
_this8._element.focus();
} else {
_this8.hide();
}
});
if (animate) {
Util.reflow(this._backdrop);
}
$(this._backdrop).addClass(ClassName$5.SHOW);
if (!callback) {
return;
}
if (!animate) {
callback();
return;
}
var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
$(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
} else if (!this._isShown && this._backdrop) {
$(this._backdrop).removeClass(ClassName$5.SHOW);
var callbackRemove = function callbackRemove() {
_this8._removeBackdrop();
if (callback) {
callback();
}
};
if ($(this._element).hasClass(ClassName$5.FADE)) {
var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
$(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
} else {
callbackRemove();
}
} else if (callback) {
callback();
}
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
;
_proto._adjustDialog = function _adjustDialog() {
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (!this._isBodyOverflowing && isModalOverflowing) {
this._element.style.paddingLeft = this._scrollbarWidth + "px";
}
if (this._isBodyOverflowing && !isModalOverflowing) {
this._element.style.paddingRight = this._scrollbarWidth + "px";
}
};
_proto._resetAdjustments = function _resetAdjustments() {
this._element.style.paddingLeft = '';
this._element.style.paddingRight = '';
};
_proto._checkScrollbar = function _checkScrollbar() {
var rect = document.body.getBoundingClientRect();
this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
this._scrollbarWidth = this._getScrollbarWidth();
};
_proto._setScrollbar = function _setScrollbar() {
var _this9 = this;
if (this._isBodyOverflowing) {
// Note: DOMNode.style.paddingRight returns the actual value or '' if not set
// while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
$(fixedContent).each(function (index, element) {
var actualPadding = element.style.paddingRight;
var calculatedPadding = $(element).css('padding-right');
$(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px");
}); // Adjust sticky content margin
$(stickyContent).each(function (index, element) {
var actualMargin = element.style.marginRight;
var calculatedMargin = $(element).css('margin-right');
$(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px");
}); // Adjust body padding
var actualPadding = document.body.style.paddingRight;
var calculatedPadding = $(document.body).css('padding-right');
$(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
}
$(document.body).addClass(ClassName$5.OPEN);
};
_proto._resetScrollbar = function _resetScrollbar() {
// Restore fixed content padding
var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
$(fixedContent).each(function (index, element) {
var padding = $(element).data('padding-right');
$(element).removeData('padding-right');
element.style.paddingRight = padding ? padding : '';
}); // Restore sticky content
var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
$(elements).each(function (index, element) {
var margin = $(element).data('margin-right');
if (typeof margin !== 'undefined') {
$(element).css('margin-right', margin).removeData('margin-right');
}
}); // Restore body padding
var padding = $(document.body).data('padding-right');
$(document.body).removeData('padding-right');
document.body.style.paddingRight = padding ? padding : '';
};
_proto._getScrollbarWidth = function _getScrollbarWidth() {
// thx d.walsh
var scrollDiv = document.createElement('div');
scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
} // Static
;
Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
return this.each(function () {
var data = $(this).data(DATA_KEY$5);
var _config = _objectSpread({}, Default$3, $(this).data(), typeof config === 'object' && config ? config : {});
if (!data) {
data = new Modal(this, _config);
$(this).data(DATA_KEY$5, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config](relatedTarget);
} else if (_config.show) {
data.show(relatedTarget);
}
});
};
_createClass(Modal, null, [{
key: "VERSION",
get: function get() {
return VERSION$5;
}
}, {
key: "Default",
get: function get() {
return Default$3;
}
}]);
return Modal;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
var _this10 = this;
var target;
var selector = Util.getSelectorFromElement(this);
if (selector) {
target = document.querySelector(selector);
}
var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data());
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault();
}
var $target = $(target).one(Event$5.SHOW, function (showEvent) {
if (showEvent.isDefaultPrevented()) {
// Only register focus restorer if modal will actually get shown
return;
}
$target.one(Event$5.HIDDEN, function () {
if ($(_this10).is(':visible')) {
_this10.focus();
}
});
});
Modal._jQueryInterface.call($(target), config, this);
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$5] = Modal._jQueryInterface;
$.fn[NAME$5].Constructor = Modal;
$.fn[NAME$5].noConflict = function () {
$.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
return Modal._jQueryInterface;
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.3.1): tools/sanitizer.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
var DefaultWhitelist = {
// Global attributes allowed on any supplied element below.
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
a: ['target', 'href', 'title', 'rel'],
area: [],
b: [],
br: [],
col: [],
code: [],
div: [],
em: [],
hr: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
i: [],
img: ['src', 'alt', 'title', 'width', 'height'],
li: [],
ol: [],
p: [],
pre: [],
s: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
u: [],
ul: []
/**
* A pattern that recognizes a commonly useful subset of URLs that are safe.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
};
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio types.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
function allowedAttribute(attr, allowedAttributeList) {
var attrName = attr.nodeName.toLowerCase();
if (allowedAttributeList.indexOf(attrName) !== -1) {
if (uriAttrs.indexOf(attrName) !== -1) {
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
}
return true;
}
var regExp = allowedAttributeList.filter(function (attrRegex) {
return attrRegex instanceof RegExp;
}); // Check if a regular expression validates the attribute.
for (var i = 0, l = regExp.length; i < l; i++) {
if (attrName.match(regExp[i])) {
return true;
}
}
return false;
}
function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
if (unsafeHtml.length === 0) {
return unsafeHtml;
}
if (sanitizeFn && typeof sanitizeFn === 'function') {
return sanitizeFn(unsafeHtml);
}
var domParser = new window.DOMParser();
var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
var whitelistKeys = Object.keys(whiteList);
var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
var _loop = function _loop(i, len) {
var el = elements[i];
var elName = el.nodeName.toLowerCase();
if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
el.parentNode.removeChild(el);
return "continue";
}
var attributeList = [].slice.call(el.attributes);
var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
attributeList.forEach(function (attr) {
if (!allowedAttribute(attr, whitelistedAttributes)) {
el.removeAttribute(attr.nodeName);
}
});
};
for (var i = 0, len = elements.length; i < len; i++) {
var _ret = _loop(i, len);
if (_ret === "continue") continue;
}
return createdDocument.body.innerHTML;
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$6 = 'tooltip';
var VERSION$6 = '4.3.1';
var DATA_KEY$6 = 'bs.tooltip';
var EVENT_KEY$6 = "." + DATA_KEY$6;
var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
var CLASS_PREFIX = 'bs-tooltip';
var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
var DefaultType$4 = {
animation: 'boolean',
template: 'string',
title: '(string|element|function)',
trigger: 'string',
delay: '(number|object)',
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
offset: '(number|string|function)',
container: '(string|element|boolean)',
fallbackPlacement: '(string|array)',
boundary: '(string|element)',
sanitize: 'boolean',
sanitizeFn: '(null|function)',
whiteList: 'object'
};
var AttachmentMap$1 = {
AUTO: 'auto',
TOP: 'top',
RIGHT: 'right',
BOTTOM: 'bottom',
LEFT: 'left'
};
var Default$4 = {
animation: true,
template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
selector: false,
placement: 'top',
offset: 0,
container: false,
fallbackPlacement: 'flip',
boundary: 'scrollParent',
sanitize: true,
sanitizeFn: null,
whiteList: DefaultWhitelist
};
var HoverState = {
SHOW: 'show',
OUT: 'out'
};
var Event$6 = {
HIDE: "hide" + EVENT_KEY$6,
HIDDEN: "hidden" + EVENT_KEY$6,
SHOW: "show" + EVENT_KEY$6,
SHOWN: "shown" + EVENT_KEY$6,
INSERTED: "inserted" + EVENT_KEY$6,
CLICK: "click" + EVENT_KEY$6,
FOCUSIN: "focusin" + EVENT_KEY$6,
FOCUSOUT: "focusout" + EVENT_KEY$6,
MOUSEENTER: "mouseenter" + EVENT_KEY$6,
MOUSELEAVE: "mouseleave" + EVENT_KEY$6
};
var ClassName$6 = {
FADE: 'fade',
SHOW: 'show'
};
var Selector$6 = {
TOOLTIP: '.tooltip',
TOOLTIP_INNER: '.tooltip-inner',
ARROW: '.arrow'
};
var Trigger = {
HOVER: 'hover',
FOCUS: 'focus',
CLICK: 'click',
MANUAL: 'manual'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Tooltip =
/*#__PURE__*/
function () {
function Tooltip(element, config) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
} // private
this._isEnabled = true;
this._timeout = 0;
this._hoverState = '';
this._activeTrigger = {};
this._popper = null; // Protected
this.element = element;
this.config = this._getConfig(config);
this.tip = null;
this._setListeners();
} // Getters
var _proto = Tooltip.prototype;
// Public
_proto.enable = function enable() {
this._isEnabled = true;
};
_proto.disable = function disable() {
this._isEnabled = false;
};
_proto.toggleEnabled = function toggleEnabled() {
this._isEnabled = !this._isEnabled;
};
_proto.toggle = function toggle(event) {
if (!this._isEnabled) {
return;
}
if (event) {
var dataKey = this.constructor.DATA_KEY;
var context = $(event.currentTarget).data(dataKey);
if (!context) {
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
$(event.currentTarget).data(dataKey, context);
}
context._activeTrigger.click = !context._activeTrigger.click;
if (context._isWithActiveTrigger()) {
context._enter(null, context);
} else {
context._leave(null, context);
}
} else {
if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
this._leave(null, this);
return;
}
this._enter(null, this);
}
};
_proto.dispose = function dispose() {
clearTimeout(this._timeout);
$.removeData(this.element, this.constructor.DATA_KEY);
$(this.element).off(this.constructor.EVENT_KEY);
$(this.element).closest('.modal').off('hide.bs.modal');
if (this.tip) {
$(this.tip).remove();
}
this._isEnabled = null;
this._timeout = null;
this._hoverState = null;
this._activeTrigger = null;
if (this._popper !== null) {
this._popper.destroy();
}
this._popper = null;
this.element = null;
this.config = null;
this.tip = null;
};
_proto.show = function show() {
var _this = this;
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements');
}
var showEvent = $.Event(this.constructor.Event.SHOW);
if (this.isWithContent() && this._isEnabled) {
$(this.element).trigger(showEvent);
var shadowRoot = Util.findShadowRoot(this.element);
var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
if (showEvent.isDefaultPrevented() || !isInTheDom) {
return;
}
var tip = this.getTipElement();
var tipId = Util.getUID(this.constructor.NAME);
tip.setAttribute('id', tipId);
this.element.setAttribute('aria-describedby', tipId);
this.setContent();
if (this.config.animation) {
$(tip).addClass(ClassName$6.FADE);
}
var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
var attachment = this._getAttachment(placement);
this.addAttachmentClass(attachment);
var container = this._getContainer();
$(tip).data(this.constructor.DATA_KEY, this);
if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
$(tip).appendTo(container);
}
$(this.element).trigger(this.constructor.Event.INSERTED);
this._popper = new Popper(this.element, tip, {
placement: attachment,
modifiers: {
offset: this._getOffset(),
flip: {
behavior: this.config.fallbackPlacement
},
arrow: {
element: Selector$6.ARROW
},
preventOverflow: {
boundariesElement: this.config.boundary
}
},
onCreate: function onCreate(data) {
if (data.originalPlacement !== data.placement) {
_this._handlePopperPlacementChange(data);
}
},
onUpdate: function onUpdate(data) {
return _this._handlePopperPlacementChange(data);
}
});
$(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement) {
$(document.body).children().on('mouseover', null, $.noop);
}
var complete = function complete() {
if (_this.config.animation) {
_this._fixTransition();
}
var prevHoverState = _this._hoverState;
_this._hoverState = null;
$(_this.element).trigger(_this.constructor.Event.SHOWN);
if (prevHoverState === HoverState.OUT) {
_this._leave(null, _this);
}
};
if ($(this.tip).hasClass(ClassName$6.FADE)) {
var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
$(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
} else {
complete();
}
}
};
_proto.hide = function hide(callback) {
var _this2 = this;
var tip = this.getTipElement();
var hideEvent = $.Event(this.constructor.Event.HIDE);
var complete = function complete() {
if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip);
}
_this2._cleanTipClass();
_this2.element.removeAttribute('aria-describedby');
$(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
if (_this2._popper !== null) {
_this2._popper.destroy();
}
if (callback) {
callback();
}
};
$(this.element).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
return;
}
$(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$(document.body).children().off('mouseover', null, $.noop);
}
this._activeTrigger[Trigger.CLICK] = false;
this._activeTrigger[Trigger.FOCUS] = false;
this._activeTrigger[Trigger.HOVER] = false;
if ($(this.tip).hasClass(ClassName$6.FADE)) {
var transitionDuration = Util.getTransitionDurationFromElement(tip);
$(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
} else {
complete();
}
this._hoverState = '';
};
_proto.update = function update() {
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
} // Protected
;
_proto.isWithContent = function isWithContent() {
return Boolean(this.getTitle());
};
_proto.addAttachmentClass = function addAttachmentClass(attachment) {
$(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
};
_proto.getTipElement = function getTipElement() {
this.tip = this.tip || $(this.config.template)[0];
return this.tip;
};
_proto.setContent = function setContent() {
var tip = this.getTipElement();
this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
$(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
};
_proto.setElementContent = function setElementContent($element, content) {
if (typeof content === 'object' && (content.nodeType || content.jquery)) {
// Content is a DOM node or a jQuery
if (this.config.html) {
if (!$(content).parent().is($element)) {
$element.empty().append(content);
}
} else {
$element.text($(content).text());
}
return;
}
if (this.config.html) {
if (this.config.sanitize) {
content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
}
$element.html(content);
} else {
$element.text(content);
}
};
_proto.getTitle = function getTitle() {
var title = this.element.getAttribute('data-original-title');
if (!title) {
title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
}
return title;
} // Private
;
_proto._getOffset = function _getOffset() {
var _this3 = this;
var offset = {};
if (typeof this.config.offset === 'function') {
offset.fn = function (data) {
data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {});
return data;
};
} else {
offset.offset = this.config.offset;
}
return offset;
};
_proto._getContainer = function _getContainer() {
if (this.config.container === false) {
return document.body;
}
if (Util.isElement(this.config.container)) {
return $(this.config.container);
}
return $(document).find(this.config.container);
};
_proto._getAttachment = function _getAttachment(placement) {
return AttachmentMap$1[placement.toUpperCase()];
};
_proto._setListeners = function _setListeners() {
var _this4 = this;
var triggers = this.config.trigger.split(' ');
triggers.forEach(function (trigger) {
if (trigger === 'click') {
$(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) {
return _this4.toggle(event);
});
} else if (trigger !== Trigger.MANUAL) {
var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN;
var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT;
$(_this4.element).on(eventIn, _this4.config.selector, function (event) {
return _this4._enter(event);
}).on(eventOut, _this4.config.selector, function (event) {
return _this4._leave(event);
});
}
});
$(this.element).closest('.modal').on('hide.bs.modal', function () {
if (_this4.element) {
_this4.hide();
}
});
if (this.config.selector) {
this.config = _objectSpread({}, this.config, {
trigger: 'manual',
selector: ''
});
} else {
this._fixTitle();
}
};
_proto._fixTitle = function _fixTitle() {
var titleType = typeof this.element.getAttribute('data-original-title');
if (this.element.getAttribute('title') || titleType !== 'string') {
this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
this.element.setAttribute('title', '');
}
};
_proto._enter = function _enter(event, context) {
var dataKey = this.constructor.DATA_KEY;
context = context || $(event.currentTarget).data(dataKey);
if (!context) {
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
$(event.currentTarget).data(dataKey, context);
}
if (event) {
context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
}
if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
context._hoverState = HoverState.SHOW;
return;
}
clearTimeout(context._timeout);
context._hoverState = HoverState.SHOW;
if (!context.config.delay || !context.config.delay.show) {
context.show();
return;
}
context._timeout = setTimeout(function () {
if (context._hoverState === HoverState.SHOW) {
context.show();
}
}, context.config.delay.show);
};
_proto._leave = function _leave(event, context) {
var dataKey = this.constructor.DATA_KEY;
context = context || $(event.currentTarget).data(dataKey);
if (!context) {
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
$(event.currentTarget).data(dataKey, context);
}
if (event) {
context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
}
if (context._isWithActiveTrigger()) {
return;
}
clearTimeout(context._timeout);
context._hoverState = HoverState.OUT;
if (!context.config.delay || !context.config.delay.hide) {
context.hide();
return;
}
context._timeout = setTimeout(function () {
if (context._hoverState === HoverState.OUT) {
context.hide();
}
}, context.config.delay.hide);
};
_proto._isWithActiveTrigger = function _isWithActiveTrigger() {
for (var trigger in this._activeTrigger) {
if (this._activeTrigger[trigger]) {
return true;
}
}
return false;
};
_proto._getConfig = function _getConfig(config) {
var dataAttributes = $(this.element).data();
Object.keys(dataAttributes).forEach(function (dataAttr) {
if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
delete dataAttributes[dataAttr];
}
});
config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
if (typeof config.delay === 'number') {
config.delay = {
show: config.delay,
hide: config.delay
};
}
if (typeof config.title === 'number') {
config.title = config.title.toString();
}
if (typeof config.content === 'number') {
config.content = config.content.toString();
}
Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
if (config.sanitize) {
config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
}
return config;
};
_proto._getDelegateConfig = function _getDelegateConfig() {
var config = {};
if (this.config) {
for (var key in this.config) {
if (this.constructor.Default[key] !== this.config[key]) {
config[key] = this.config[key];
}
}
}
return config;
};
_proto._cleanTipClass = function _cleanTipClass() {
var $tip = $(this.getTipElement());
var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
if (tabClass !== null && tabClass.length) {
$tip.removeClass(tabClass.join(''));
}
};
_proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
var popperInstance = popperData.instance;
this.tip = popperInstance.popper;
this._cleanTipClass();
this.addAttachmentClass(this._getAttachment(popperData.placement));
};
_proto._fixTransition = function _fixTransition() {
var tip = this.getTipElement();
var initConfigAnimation = this.config.animation;
if (tip.getAttribute('x-placement') !== null) {
return;
}
$(tip).removeClass(ClassName$6.FADE);
this.config.animation = false;
this.hide();
this.show();
this.config.animation = initConfigAnimation;
} // Static
;
Tooltip._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$6);
var _config = typeof config === 'object' && config;
if (!data && /dispose|hide/.test(config)) {
return;
}
if (!data) {
data = new Tooltip(this, _config);
$(this).data(DATA_KEY$6, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
_createClass(Tooltip, null, [{
key: "VERSION",
get: function get() {
return VERSION$6;
}
}, {
key: "Default",
get: function get() {
return Default$4;
}
}, {
key: "NAME",
get: function get() {
return NAME$6;
}
}, {
key: "DATA_KEY",
get: function get() {
return DATA_KEY$6;
}
}, {
key: "Event",
get: function get() {
return Event$6;
}
}, {
key: "EVENT_KEY",
get: function get() {
return EVENT_KEY$6;
}
}, {
key: "DefaultType",
get: function get() {
return DefaultType$4;
}
}]);
return Tooltip;
}();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$6] = Tooltip._jQueryInterface;
$.fn[NAME$6].Constructor = Tooltip;
$.fn[NAME$6].noConflict = function () {
$.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
return Tooltip._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$7 = 'popover';
var VERSION$7 = '4.3.1';
var DATA_KEY$7 = 'bs.popover';
var EVENT_KEY$7 = "." + DATA_KEY$7;
var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
var CLASS_PREFIX$1 = 'bs-popover';
var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
var Default$5 = _objectSpread({}, Tooltip.Default, {
placement: 'right',
trigger: 'click',
content: '',
template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
});
var DefaultType$5 = _objectSpread({}, Tooltip.DefaultType, {
content: '(string|element|function)'
});
var ClassName$7 = {
FADE: 'fade',
SHOW: 'show'
};
var Selector$7 = {
TITLE: '.popover-header',
CONTENT: '.popover-body'
};
var Event$7 = {
HIDE: "hide" + EVENT_KEY$7,
HIDDEN: "hidden" + EVENT_KEY$7,
SHOW: "show" + EVENT_KEY$7,
SHOWN: "shown" + EVENT_KEY$7,
INSERTED: "inserted" + EVENT_KEY$7,
CLICK: "click" + EVENT_KEY$7,
FOCUSIN: "focusin" + EVENT_KEY$7,
FOCUSOUT: "focusout" + EVENT_KEY$7,
MOUSEENTER: "mouseenter" + EVENT_KEY$7,
MOUSELEAVE: "mouseleave" + EVENT_KEY$7
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Popover =
/*#__PURE__*/
function (_Tooltip) {
_inheritsLoose(Popover, _Tooltip);
function Popover() {
return _Tooltip.apply(this, arguments) || this;
}
var _proto = Popover.prototype;
// Overrides
_proto.isWithContent = function isWithContent() {
return this.getTitle() || this._getContent();
};
_proto.addAttachmentClass = function addAttachmentClass(attachment) {
$(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
};
_proto.getTipElement = function getTipElement() {
this.tip = this.tip || $(this.config.template)[0];
return this.tip;
};
_proto.setContent = function setContent() {
var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
var content = this._getContent();
if (typeof content === 'function') {
content = content.call(this.element);
}
this.setElementContent($tip.find(Selector$7.CONTENT), content);
$tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
} // Private
;
_proto._getContent = function _getContent() {
return this.element.getAttribute('data-content') || this.config.content;
};
_proto._cleanTipClass = function _cleanTipClass() {
var $tip = $(this.getTipElement());
var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
if (tabClass !== null && tabClass.length > 0) {
$tip.removeClass(tabClass.join(''));
}
} // Static
;
Popover._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$7);
var _config = typeof config === 'object' ? config : null;
if (!data && /dispose|hide/.test(config)) {
return;
}
if (!data) {
data = new Popover(this, _config);
$(this).data(DATA_KEY$7, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
_createClass(Popover, null, [{
key: "VERSION",
// Getters
get: function get() {
return VERSION$7;
}
}, {
key: "Default",
get: function get() {
return Default$5;
}
}, {
key: "NAME",
get: function get() {
return NAME$7;
}
}, {
key: "DATA_KEY",
get: function get() {
return DATA_KEY$7;
}
}, {
key: "Event",
get: function get() {
return Event$7;
}
}, {
key: "EVENT_KEY",
get: function get() {
return EVENT_KEY$7;
}
}, {
key: "DefaultType",
get: function get() {
return DefaultType$5;
}
}]);
return Popover;
}(Tooltip);
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$7] = Popover._jQueryInterface;
$.fn[NAME$7].Constructor = Popover;
$.fn[NAME$7].noConflict = function () {
$.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
return Popover._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$8 = 'scrollspy';
var VERSION$8 = '4.3.1';
var DATA_KEY$8 = 'bs.scrollspy';
var EVENT_KEY$8 = "." + DATA_KEY$8;
var DATA_API_KEY$6 = '.data-api';
var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
var Default$6 = {
offset: 10,
method: 'auto',
target: ''
};
var DefaultType$6 = {
offset: 'number',
method: 'string',
target: '(string|element)'
};
var Event$8 = {
ACTIVATE: "activate" + EVENT_KEY$8,
SCROLL: "scroll" + EVENT_KEY$8,
LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
};
var ClassName$8 = {
DROPDOWN_ITEM: 'dropdown-item',
DROPDOWN_MENU: 'dropdown-menu',
ACTIVE: 'active'
};
var Selector$8 = {
DATA_SPY: '[data-spy="scroll"]',
ACTIVE: '.active',
NAV_LIST_GROUP: '.nav, .list-group',
NAV_LINKS: '.nav-link',
NAV_ITEMS: '.nav-item',
LIST_ITEMS: '.list-group-item',
DROPDOWN: '.dropdown',
DROPDOWN_ITEMS: '.dropdown-item',
DROPDOWN_TOGGLE: '.dropdown-toggle'
};
var OffsetMethod = {
OFFSET: 'offset',
POSITION: 'position'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var ScrollSpy =
/*#__PURE__*/
function () {
function ScrollSpy(element, config) {
var _this = this;
this._element = element;
this._scrollElement = element.tagName === 'BODY' ? window : element;
this._config = this._getConfig(config);
this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
this._offsets = [];
this._targets = [];
this._activeTarget = null;
this._scrollHeight = 0;
$(this._scrollElement).on(Event$8.SCROLL, function (event) {
return _this._process(event);
});
this.refresh();
this._process();
} // Getters
var _proto = ScrollSpy.prototype;
// Public
_proto.refresh = function refresh() {
var _this2 = this;
var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
var targets = [].slice.call(document.querySelectorAll(this._selector));
targets.map(function (element) {
var target;
var targetSelector = Util.getSelectorFromElement(element);
if (targetSelector) {
target = document.querySelector(targetSelector);
}
if (target) {
var targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
// TODO (fat): remove sketch reliance on jQuery position/offset
return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
}
return null;
}).filter(function (item) {
return item;
}).sort(function (a, b) {
return a[0] - b[0];
}).forEach(function (item) {
_this2._offsets.push(item[0]);
_this2._targets.push(item[1]);
});
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY$8);
$(this._scrollElement).off(EVENT_KEY$8);
this._element = null;
this._scrollElement = null;
this._config = null;
this._selector = null;
this._offsets = null;
this._targets = null;
this._activeTarget = null;
this._scrollHeight = null;
} // Private
;
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, Default$6, typeof config === 'object' && config ? config : {});
if (typeof config.target !== 'string') {
var id = $(config.target).attr('id');
if (!id) {
id = Util.getUID(NAME$8);
$(config.target).attr('id', id);
}
config.target = "#" + id;
}
Util.typeCheckConfig(NAME$8, config, DefaultType$6);
return config;
};
_proto._getScrollTop = function _getScrollTop() {
return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
};
_proto._getScrollHeight = function _getScrollHeight() {
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
};
_proto._getOffsetHeight = function _getOffsetHeight() {
return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
};
_proto._process = function _process() {
var scrollTop = this._getScrollTop() + this._config.offset;
var scrollHeight = this._getScrollHeight();
var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
if (this._scrollHeight !== scrollHeight) {
this.refresh();
}
if (scrollTop >= maxScroll) {
var target = this._targets[this._targets.length - 1];
if (this._activeTarget !== target) {
this._activate(target);
}
return;
}
if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
this._activeTarget = null;
this._clear();
return;
}
var offsetLength = this._offsets.length;
for (var i = offsetLength; i--;) {
var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
if (isActiveTarget) {
this._activate(this._targets[i]);
}
}
};
_proto._activate = function _activate(target) {
this._activeTarget = target;
this._clear();
var queries = this._selector.split(',').map(function (selector) {
return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
});
var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
$link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
$link.addClass(ClassName$8.ACTIVE);
} else {
// Set triggered link as active
$link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
$link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); // Handle special case when .nav-link is inside .nav-item
$link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
}
$(this._scrollElement).trigger(Event$8.ACTIVATE, {
relatedTarget: target
});
};
_proto._clear = function _clear() {
[].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
return node.classList.contains(ClassName$8.ACTIVE);
}).forEach(function (node) {
return node.classList.remove(ClassName$8.ACTIVE);
});
} // Static
;
ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY$8);
var _config = typeof config === 'object' && config;
if (!data) {
data = new ScrollSpy(this, _config);
$(this).data(DATA_KEY$8, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
_createClass(ScrollSpy, null, [{
key: "VERSION",
get: function get() {
return VERSION$8;
}
}, {
key: "Default",
get: function get() {
return Default$6;
}
}]);
return ScrollSpy;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(window).on(Event$8.LOAD_DATA_API, function () {
var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
var scrollSpysLength = scrollSpys.length;
for (var i = scrollSpysLength; i--;) {
var $spy = $(scrollSpys[i]);
ScrollSpy._jQueryInterface.call($spy, $spy.data());
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$8] = ScrollSpy._jQueryInterface;
$.fn[NAME$8].Constructor = ScrollSpy;
$.fn[NAME$8].noConflict = function () {
$.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
return ScrollSpy._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$9 = 'tab';
var VERSION$9 = '4.3.1';
var DATA_KEY$9 = 'bs.tab';
var EVENT_KEY$9 = "." + DATA_KEY$9;
var DATA_API_KEY$7 = '.data-api';
var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
var Event$9 = {
HIDE: "hide" + EVENT_KEY$9,
HIDDEN: "hidden" + EVENT_KEY$9,
SHOW: "show" + EVENT_KEY$9,
SHOWN: "shown" + EVENT_KEY$9,
CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
};
var ClassName$9 = {
DROPDOWN_MENU: 'dropdown-menu',
ACTIVE: 'active',
DISABLED: 'disabled',
FADE: 'fade',
SHOW: 'show'
};
var Selector$9 = {
DROPDOWN: '.dropdown',
NAV_LIST_GROUP: '.nav, .list-group',
ACTIVE: '.active',
ACTIVE_UL: '> li > .active',
DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
DROPDOWN_TOGGLE: '.dropdown-toggle',
DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Tab =
/*#__PURE__*/
function () {
function Tab(element) {
this._element = element;
} // Getters
var _proto = Tab.prototype;
// Public
_proto.show = function show() {
var _this = this;
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
return;
}
var target;
var previous;
var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
var selector = Util.getSelectorFromElement(this._element);
if (listElement) {
var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
previous = $.makeArray($(listElement).find(itemSelector));
previous = previous[previous.length - 1];
}
var hideEvent = $.Event(Event$9.HIDE, {
relatedTarget: this._element
});
var showEvent = $.Event(Event$9.SHOW, {
relatedTarget: previous
});
if (previous) {
$(previous).trigger(hideEvent);
}
$(this._element).trigger(showEvent);
if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
return;
}
if (selector) {
target = document.querySelector(selector);
}
this._activate(this._element, listElement);
var complete = function complete() {
var hiddenEvent = $.Event(Event$9.HIDDEN, {
relatedTarget: _this._element
});
var shownEvent = $.Event(Event$9.SHOWN, {
relatedTarget: previous
});
$(previous).trigger(hiddenEvent);
$(_this._element).trigger(shownEvent);
};
if (target) {
this._activate(target, target.parentNode, complete);
} else {
complete();
}
};
_proto.dispose = function dispose() {
$.removeData(this._element, DATA_KEY$9);
this._element = null;
} // Private
;
_proto._activate = function _activate(element, container, callback) {
var _this2 = this;
var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
var active = activeElements[0];
var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
var complete = function complete() {
return _this2._transitionComplete(element, active, callback);
};
if (active && isTransitioning) {
var transitionDuration = Util.getTransitionDurationFromElement(active);
$(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
} else {
complete();
}
};
_proto._transitionComplete = function _transitionComplete(element, active, callback) {
if (active) {
$(active).removeClass(ClassName$9.ACTIVE);
var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
if (dropdownChild) {
$(dropdownChild).removeClass(ClassName$9.ACTIVE);
}
if (active.getAttribute('role') === 'tab') {
active.setAttribute('aria-selected', false);
}
}
$(element).addClass(ClassName$9.ACTIVE);
if (element.getAttribute('role') === 'tab') {
element.setAttribute('aria-selected', true);
}
Util.reflow(element);
if (element.classList.contains(ClassName$9.FADE)) {
element.classList.add(ClassName$9.SHOW);
}
if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
if (dropdownElement) {
var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
$(dropdownToggleList).addClass(ClassName$9.ACTIVE);
}
element.setAttribute('aria-expanded', true);
}
if (callback) {
callback();
}
} // Static
;
Tab._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DATA_KEY$9);
if (!data) {
data = new Tab(this);
$this.data(DATA_KEY$9, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config]();
}
});
};
_createClass(Tab, null, [{
key: "VERSION",
get: function get() {
return VERSION$9;
}
}]);
return Tab;
}();
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
event.preventDefault();
Tab._jQueryInterface.call($(this), 'show');
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$9] = Tab._jQueryInterface;
$.fn[NAME$9].Constructor = Tab;
$.fn[NAME$9].noConflict = function () {
$.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
return Tab._jQueryInterface;
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$a = 'toast';
var VERSION$a = '4.3.1';
var DATA_KEY$a = 'bs.toast';
var EVENT_KEY$a = "." + DATA_KEY$a;
var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
var Event$a = {
CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
HIDE: "hide" + EVENT_KEY$a,
HIDDEN: "hidden" + EVENT_KEY$a,
SHOW: "show" + EVENT_KEY$a,
SHOWN: "shown" + EVENT_KEY$a
};
var ClassName$a = {
FADE: 'fade',
HIDE: 'hide',
SHOW: 'show',
SHOWING: 'showing'
};
var DefaultType$7 = {
animation: 'boolean',
autohide: 'boolean',
delay: 'number'
};
var Default$7 = {
animation: true,
autohide: true,
delay: 500
};
var Selector$a = {
DATA_DISMISS: '[data-dismiss="toast"]'
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
};
var Toast =
/*#__PURE__*/
function () {
function Toast(element, config) {
this._element = element;
this._config = this._getConfig(config);
this._timeout = null;
this._setListeners();
} // Getters
var _proto = Toast.prototype;
// Public
_proto.show = function show() {
var _this = this;
$(this._element).trigger(Event$a.SHOW);
if (this._config.animation) {
this._element.classList.add(ClassName$a.FADE);
}
var complete = function complete() {
_this._element.classList.remove(ClassName$a.SHOWING);
_this._element.classList.add(ClassName$a.SHOW);
$(_this._element).trigger(Event$a.SHOWN);
if (_this._config.autohide) {
_this.hide();
}
};
this._element.classList.remove(ClassName$a.HIDE);
this._element.classList.add(ClassName$a.SHOWING);
if (this._config.animation) {
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
} else {
complete();
}
};
_proto.hide = function hide(withoutTimeout) {
var _this2 = this;
if (!this._element.classList.contains(ClassName$a.SHOW)) {
return;
}
$(this._element).trigger(Event$a.HIDE);
if (withoutTimeout) {
this._close();
} else {
this._timeout = setTimeout(function () {
_this2._close();
}, this._config.delay);
}
};
_proto.dispose = function dispose() {
clearTimeout(this._timeout);
this._timeout = null;
if (this._element.classList.contains(ClassName$a.SHOW)) {
this._element.classList.remove(ClassName$a.SHOW);
}
$(this._element).off(Event$a.CLICK_DISMISS);
$.removeData(this._element, DATA_KEY$a);
this._element = null;
this._config = null;
} // Private
;
_proto._getConfig = function _getConfig(config) {
config = _objectSpread({}, Default$7, $(this._element).data(), typeof config === 'object' && config ? config : {});
Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
return config;
};
_proto._setListeners = function _setListeners() {
var _this3 = this;
$(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
return _this3.hide(true);
});
};
_proto._close = function _close() {
var _this4 = this;
var complete = function complete() {
_this4._element.classList.add(ClassName$a.HIDE);
$(_this4._element).trigger(Event$a.HIDDEN);
};
this._element.classList.remove(ClassName$a.SHOW);
if (this._config.animation) {
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
} else {
complete();
}
} // Static
;
Toast._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var $element = $(this);
var data = $element.data(DATA_KEY$a);
var _config = typeof config === 'object' && config;
if (!data) {
data = new Toast(this, _config);
$element.data(DATA_KEY$a, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError("No method named \"" + config + "\"");
}
data[config](this);
}
});
};
_createClass(Toast, null, [{
key: "VERSION",
get: function get() {
return VERSION$a;
}
}, {
key: "DefaultType",
get: function get() {
return DefaultType$7;
}
}, {
key: "Default",
get: function get() {
return Default$7;
}
}]);
return Toast;
}();
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$a] = Toast._jQueryInterface;
$.fn[NAME$a].Constructor = Toast;
$.fn[NAME$a].noConflict = function () {
$.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
return Toast._jQueryInterface;
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.3.1): index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
(function () {
if (typeof $ === 'undefined') {
throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
}
var version = $.fn.jquery.split(' ')[0].split('.');
var minMajor = 1;
var ltMajor = 2;
var minMinor = 9;
var minPatch = 1;
var maxMajor = 4;
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
}
})();
exports.Util = Util;
exports.Alert = Alert;
exports.Button = Button;
exports.Carousel = Carousel;
exports.Collapse = Collapse;
exports.Dropdown = Dropdown;
exports.Modal = Modal;
exports.Popover = Popover;
exports.Scrollspy = ScrollSpy;
exports.Tab = Tab;
exports.Toast = Toast;
exports.Tooltip = Tooltip;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=bootstrap.js.map
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* WEBPACK VAR INJECTION */(function(global) {/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.0
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
var timeoutDuration = function () {
var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
return 1;
}
}
return 0;
}();
function microtaskDebounce(fn) {
var called = false;
return function () {
if (called) {
return;
}
called = true;
window.Promise.resolve().then(function () {
called = false;
fn();
});
};
}
function taskDebounce(fn) {
var scheduled = false;
return function () {
if (!scheduled) {
scheduled = true;
setTimeout(function () {
scheduled = false;
fn();
}, timeoutDuration);
}
};
}
var supportsMicroTasks = isBrowser && window.Promise;
/**
* Create a debounced version of a method, that's asynchronously deferred
* but called in the minimum time possible.
*
* @method
* @memberof Popper.Utils
* @argument {Function} fn
* @returns {Function}
*/
var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
/**
* Check if the given variable is a function
* @method
* @memberof Popper.Utils
* @argument {Any} functionToCheck - variable to check
* @returns {Boolean} answer to: is a function?
*/
function isFunction(functionToCheck) {
var getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
}
/**
* Get CSS computed property of the given element
* @method
* @memberof Popper.Utils
* @argument {Eement} element
* @argument {String} property
*/
function getStyleComputedProperty(element, property) {
if (element.nodeType !== 1) {
return [];
}
// NOTE: 1 DOM access here
var window = element.ownerDocument.defaultView;
var css = window.getComputedStyle(element, null);
return property ? css[property] : css;
}
/**
* Returns the parentNode or the host of the element
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @returns {Element} parent
*/
function getParentNode(element) {
if (element.nodeName === 'HTML') {
return element;
}
return element.parentNode || element.host;
}
/**
* Returns the scrolling parent of the given element
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @returns {Element} scroll parent
*/
function getScrollParent(element) {
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
if (!element) {
return document.body;
}
switch (element.nodeName) {
case 'HTML':
case 'BODY':
return element.ownerDocument.body;
case '#document':
return element.body;
}
// Firefox want us to check `-x` and `-y` variations as well
var _getStyleComputedProp = getStyleComputedProperty(element),
overflow = _getStyleComputedProp.overflow,
overflowX = _getStyleComputedProp.overflowX,
overflowY = _getStyleComputedProp.overflowY;
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
return element;
}
return getScrollParent(getParentNode(element));
}
/**
* Returns the reference node of the reference object, or the reference object itself.
* @method
* @memberof Popper.Utils
* @param {Element|Object} reference - the reference element (the popper will be relative to this)
* @returns {Element} parent
*/
function getReferenceNode(reference) {
return reference && reference.referenceNode ? reference.referenceNode : reference;
}
var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
/**
* Determines if the browser is Internet Explorer
* @method
* @memberof Popper.Utils
* @param {Number} version to check
* @returns {Boolean} isIE
*/
function isIE(version) {
if (version === 11) {
return isIE11;
}
if (version === 10) {
return isIE10;
}
return isIE11 || isIE10;
}
/**
* Returns the offset parent of the given element
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @returns {Element} offset parent
*/
function getOffsetParent(element) {
if (!element) {
return document.documentElement;
}
var noOffsetParent = isIE(10) ? document.body : null;
// NOTE: 1 DOM access here
var offsetParent = element.offsetParent || null;
// Skip hidden elements which don't have an offsetParent
while (offsetParent === noOffsetParent && element.nextElementSibling) {
offsetParent = (element = element.nextElementSibling).offsetParent;
}
var nodeName = offsetParent && offsetParent.nodeName;
if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
return element ? element.ownerDocument.documentElement : document.documentElement;
}
// .offsetParent will return the closest TH, TD or TABLE in case
// no offsetParent is present, I hate this job...
if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
return getOffsetParent(offsetParent);
}
return offsetParent;
}
function isOffsetContainer(element) {
var nodeName = element.nodeName;
if (nodeName === 'BODY') {
return false;
}
return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
}
/**
* Finds the root node (document, shadowDOM root) of the given element
* @method
* @memberof Popper.Utils
* @argument {Element} node
* @returns {Element} root node
*/
function getRoot(node) {
if (node.parentNode !== null) {
return getRoot(node.parentNode);
}
return node;
}
/**
* Finds the offset parent common to the two provided nodes
* @method
* @memberof Popper.Utils
* @argument {Element} element1
* @argument {Element} element2
* @returns {Element} common offset parent
*/
function findCommonOffsetParent(element1, element2) {
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
return document.documentElement;
}
// Here we make sure to give as "start" the element that comes first in the DOM
var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
var start = order ? element1 : element2;
var end = order ? element2 : element1;
// Get common ancestor container
var range = document.createRange();
range.setStart(start, 0);
range.setEnd(end, 0);
var commonAncestorContainer = range.commonAncestorContainer;
// Both nodes are inside #document
if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
if (isOffsetContainer(commonAncestorContainer)) {
return commonAncestorContainer;
}
return getOffsetParent(commonAncestorContainer);
}
// one of the nodes is inside shadowDOM, find which one
var element1root = getRoot(element1);
if (element1root.host) {
return findCommonOffsetParent(element1root.host, element2);
} else {
return findCommonOffsetParent(element1, getRoot(element2).host);
}
}
/**
* Gets the scroll value of the given element in the given side (top and left)
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @argument {String} side `top` or `left`
* @returns {number} amount of scrolled pixels
*/
function getScroll(element) {
var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
var nodeName = element.nodeName;
if (nodeName === 'BODY' || nodeName === 'HTML') {
var html = element.ownerDocument.documentElement;
var scrollingElement = element.ownerDocument.scrollingElement || html;
return scrollingElement[upperSide];
}
return element[upperSide];
}
/*
* Sum or subtract the element scroll values (left and top) from a given rect object
* @method
* @memberof Popper.Utils
* @param {Object} rect - Rect object you want to change
* @param {HTMLElement} element - The element from the function reads the scroll values
* @param {Boolean} subtract - set to true if you want to subtract the scroll values
* @return {Object} rect - The modifier rect object
*/
function includeScroll(rect, element) {
var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var scrollTop = getScroll(element, 'top');
var scrollLeft = getScroll(element, 'left');
var modifier = subtract ? -1 : 1;
rect.top += scrollTop * modifier;
rect.bottom += scrollTop * modifier;
rect.left += scrollLeft * modifier;
rect.right += scrollLeft * modifier;
return rect;
}
/*
* Helper to detect borders of a given element
* @method
* @memberof Popper.Utils
* @param {CSSStyleDeclaration} styles
* Result of `getStyleComputedProperty` on the given element
* @param {String} axis - `x` or `y`
* @return {number} borders - The borders size of the given axis
*/
function getBordersSize(styles, axis) {
var sideA = axis === 'x' ? 'Left' : 'Top';
var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
}
function getSize(axis, body, html, computedStyle) {
return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
}
function getWindowSizes(document) {
var body = document.body;
var html = document.documentElement;
var computedStyle = isIE(10) && getComputedStyle(html);
return {
height: getSize('Height', body, html, computedStyle),
width: getSize('Width', body, html, computedStyle)
};
}
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
/**
* Given element offsets, generate an output similar to getBoundingClientRect
* @method
* @memberof Popper.Utils
* @argument {Object} offsets
* @returns {Object} ClientRect like output
*/
function getClientRect(offsets) {
return _extends({}, offsets, {
right: offsets.left + offsets.width,
bottom: offsets.top + offsets.height
});
}
/**
* Get bounding client rect of given element
* @method
* @memberof Popper.Utils
* @param {HTMLElement} element
* @return {Object} client rect
*/
function getBoundingClientRect(element) {
var rect = {};
// IE10 10 FIX: Please, don't ask, the element isn't
// considered in DOM in some circumstances...
// This isn't reproducible in IE10 compatibility mode of IE11
try {
if (isIE(10)) {
rect = element.getBoundingClientRect();
var scrollTop = getScroll(element, 'top');
var scrollLeft = getScroll(element, 'left');
rect.top += scrollTop;
rect.left += scrollLeft;
rect.bottom += scrollTop;
rect.right += scrollLeft;
} else {
rect = element.getBoundingClientRect();
}
} catch (e) {}
var result = {
left: rect.left,
top: rect.top,
width: rect.right - rect.left,
height: rect.bottom - rect.top
};
// subtract scrollbar size from sizes
var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
var width = sizes.width || element.clientWidth || result.width;
var height = sizes.height || element.clientHeight || result.height;
var horizScrollbar = element.offsetWidth - width;
var vertScrollbar = element.offsetHeight - height;
// if an hypothetical scrollbar is detected, we must be sure it's not a `border`
// we make this check conditional for performance reasons
if (horizScrollbar || vertScrollbar) {
var styles = getStyleComputedProperty(element);
horizScrollbar -= getBordersSize(styles, 'x');
vertScrollbar -= getBordersSize(styles, 'y');
result.width -= horizScrollbar;
result.height -= vertScrollbar;
}
return getClientRect(result);
}
function getOffsetRectRelativeToArbitraryNode(children, parent) {
var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var isIE10 = isIE(10);
var isHTML = parent.nodeName === 'HTML';
var childrenRect = getBoundingClientRect(children);
var parentRect = getBoundingClientRect(parent);
var scrollParent = getScrollParent(children);
var styles = getStyleComputedProperty(parent);
var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
// In cases where the parent is fixed, we must ignore negative scroll in offset calc
if (fixedPosition && isHTML) {
parentRect.top = Math.max(parentRect.top, 0);
parentRect.left = Math.max(parentRect.left, 0);
}
var offsets = getClientRect({
top: childrenRect.top - parentRect.top - borderTopWidth,
left: childrenRect.left - parentRect.left - borderLeftWidth,
width: childrenRect.width,
height: childrenRect.height
});
offsets.marginTop = 0;
offsets.marginLeft = 0;
// Subtract margins of documentElement in case it's being used as parent
// we do this only on HTML because it's the only element that behaves
// differently when margins are applied to it. The margins are included in
// the box of the documentElement, in the other cases not.
if (!isIE10 && isHTML) {
var marginTop = parseFloat(styles.marginTop, 10);
var marginLeft = parseFloat(styles.marginLeft, 10);
offsets.top -= borderTopWidth - marginTop;
offsets.bottom -= borderTopWidth - marginTop;
offsets.left -= borderLeftWidth - marginLeft;
offsets.right -= borderLeftWidth - marginLeft;
// Attach marginTop and marginLeft because in some circumstances we may need them
offsets.marginTop = marginTop;
offsets.marginLeft = marginLeft;
}
if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
offsets = includeScroll(offsets, parent);
}
return offsets;
}
function getViewportOffsetRectRelativeToArtbitraryNode(element) {
var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var html = element.ownerDocument.documentElement;
var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
var width = Math.max(html.clientWidth, window.innerWidth || 0);
var height = Math.max(html.clientHeight, window.innerHeight || 0);
var scrollTop = !excludeScroll ? getScroll(html) : 0;
var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
var offset = {
top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
width: width,
height: height
};
return getClientRect(offset);
}
/**
* Check if the given element is fixed or is inside a fixed parent
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @argument {Element} customContainer
* @returns {Boolean} answer to "isFixed?"
*/
function isFixed(element) {
var nodeName = element.nodeName;
if (nodeName === 'BODY' || nodeName === 'HTML') {
return false;
}
if (getStyleComputedProperty(element, 'position') === 'fixed') {
return true;
}
var parentNode = getParentNode(element);
if (!parentNode) {
return false;
}
return isFixed(parentNode);
}
/**
* Finds the first parent of an element that has a transformed property defined
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @returns {Element} first transformed parent or documentElement
*/
function getFixedPositionOffsetParent(element) {
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
if (!element || !element.parentElement || isIE()) {
return document.documentElement;
}
var el = element.parentElement;
while (el && getStyleComputedProperty(el, 'transform') === 'none') {
el = el.parentElement;
}
return el || document.documentElement;
}
/**
* Computed the boundaries limits and return them
* @method
* @memberof Popper.Utils
* @param {HTMLElement} popper
* @param {HTMLElement} reference
* @param {number} padding
* @param {HTMLElement} boundariesElement - Element used to define the boundaries
* @param {Boolean} fixedPosition - Is in fixed position mode
* @returns {Object} Coordinates of the boundaries
*/
function getBoundaries(popper, reference, padding, boundariesElement) {
var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
// NOTE: 1 DOM access here
var boundaries = { top: 0, left: 0 };
var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
// Handle viewport case
if (boundariesElement === 'viewport') {
boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
} else {
// Handle other cases based on DOM element used as boundaries
var boundariesNode = void 0;
if (boundariesElement === 'scrollParent') {
boundariesNode = getScrollParent(getParentNode(reference));
if (boundariesNode.nodeName === 'BODY') {
boundariesNode = popper.ownerDocument.documentElement;
}
} else if (boundariesElement === 'window') {
boundariesNode = popper.ownerDocument.documentElement;
} else {
boundariesNode = boundariesElement;
}
var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
// In case of HTML, we need a different computation
if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
var _getWindowSizes = getWindowSizes(popper.ownerDocument),
height = _getWindowSizes.height,
width = _getWindowSizes.width;
boundaries.top += offsets.top - offsets.marginTop;
boundaries.bottom = height + offsets.top;
boundaries.left += offsets.left - offsets.marginLeft;
boundaries.right = width + offsets.left;
} else {
// for all the other DOM elements, this one is good
boundaries = offsets;
}
}
// Add paddings
padding = padding || 0;
var isPaddingNumber = typeof padding === 'number';
boundaries.left += isPaddingNumber ? padding : padding.left || 0;
boundaries.top += isPaddingNumber ? padding : padding.top || 0;
boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
return boundaries;
}
function getArea(_ref) {
var width = _ref.width,
height = _ref.height;
return width * height;
}
/**
* Utility used to transform the `auto` placement to the placement with more
* available space.
* @method
* @memberof Popper.Utils
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
if (placement.indexOf('auto') === -1) {
return placement;
}
var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
var rects = {
top: {
width: boundaries.width,
height: refRect.top - boundaries.top
},
right: {
width: boundaries.right - refRect.right,
height: boundaries.height
},
bottom: {
width: boundaries.width,
height: boundaries.bottom - refRect.bottom
},
left: {
width: refRect.left - boundaries.left,
height: boundaries.height
}
};
var sortedAreas = Object.keys(rects).map(function (key) {
return _extends({
key: key
}, rects[key], {
area: getArea(rects[key])
});
}).sort(function (a, b) {
return b.area - a.area;
});
var filteredAreas = sortedAreas.filter(function (_ref2) {
var width = _ref2.width,
height = _ref2.height;
return width >= popper.clientWidth && height >= popper.clientHeight;
});
var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
var variation = placement.split('-')[1];
return computedPlacement + (variation ? '-' + variation : '');
}
/**
* Get offsets to the reference element
* @method
* @memberof Popper.Utils
* @param {Object} state
* @param {Element} popper - the popper element
* @param {Element} reference - the reference element (the popper will be relative to this)
* @param {Element} fixedPosition - is in fixed position mode
* @returns {Object} An object containing the offsets which will be applied to the popper
*/
function getReferenceOffsets(state, popper, reference) {
var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
}
/**
* Get the outer sizes of the given element (offset size + margins)
* @method
* @memberof Popper.Utils
* @argument {Element} element
* @returns {Object} object containing width and height properties
*/
function getOuterSizes(element) {
var window = element.ownerDocument.defaultView;
var styles = window.getComputedStyle(element);
var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
var result = {
width: element.offsetWidth + y,
height: element.offsetHeight + x
};
return result;
}
/**
* Get the opposite placement of the given one
* @method
* @memberof Popper.Utils
* @argument {String} placement
* @returns {String} flipped placement
*/
function getOppositePlacement(placement) {
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
return placement.replace(/left|right|bottom|top/g, function (matched) {
return hash[matched];
});
}
/**
* Get offsets to the popper
* @method
* @memberof Popper.Utils
* @param {Object} position - CSS position the Popper will get applied
* @param {HTMLElement} popper - the popper element
* @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
* @param {String} placement - one of the valid placement options
* @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
*/
function getPopperOffsets(popper, referenceOffsets, placement) {
placement = placement.split('-')[0];
// Get popper node sizes
var popperRect = getOuterSizes(popper);
// Add position, width and height to our offsets object
var popperOffsets = {
width: popperRect.width,
height: popperRect.height
};
// depending by the popper placement we have to compute its offsets slightly differently
var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
var mainSide = isHoriz ? 'top' : 'left';
var secondarySide = isHoriz ? 'left' : 'top';
var measurement = isHoriz ? 'height' : 'width';
var secondaryMeasurement = !isHoriz ? 'height' : 'width';
popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
if (placement === secondarySide) {
popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
} else {
popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
}
return popperOffsets;
}
/**
* Mimics the `find` method of Array
* @method
* @memberof Popper.Utils
* @argument {Array} arr
* @argument prop
* @argument value
* @returns index or -1
*/
function find(arr, check) {
// use native find if supported
if (Array.prototype.find) {
return arr.find(check);
}
// use `filter` to obtain the same behavior of `find`
return arr.filter(check)[0];
}
/**
* Return the index of the matching object
* @method
* @memberof Popper.Utils
* @argument {Array} arr
* @argument prop
* @argument value
* @returns index or -1
*/
function findIndex(arr, prop, value) {
// use native findIndex if supported
if (Array.prototype.findIndex) {
return arr.findIndex(function (cur) {
return cur[prop] === value;
});
}
// use `find` + `indexOf` if `findIndex` isn't supported
var match = find(arr, function (obj) {
return obj[prop] === value;
});
return arr.indexOf(match);
}
/**
* Loop trough the list of modifiers and run them in order,
* each of them will then edit the data object.
* @method
* @memberof Popper.Utils
* @param {dataObject} data
* @param {Array} modifiers
* @param {String} ends - Optional modifier name used as stopper
* @returns {dataObject}
*/
function runModifiers(modifiers, data, ends) {
var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
modifiersToRun.forEach(function (modifier) {
if (modifier['function']) {
// eslint-disable-line dot-notation
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
}
var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
if (modifier.enabled && isFunction(fn)) {
// Add properties to offsets to make them a complete clientRect object
// we do this before each modifier to make sure the previous one doesn't
// mess with these values
data.offsets.popper = getClientRect(data.offsets.popper);
data.offsets.reference = getClientRect(data.offsets.reference);
data = fn(data, modifier);
}
});
return data;
}
/**
* Updates the position of the popper, computing the new offsets and applying
* the new style.<br />
* Prefer `scheduleUpdate` over `update` because of performance reasons.
* @method
* @memberof Popper
*/
function update() {
// if popper is destroyed, don't perform any further update
if (this.state.isDestroyed) {
return;
}
var data = {
instance: this,
styles: {},
arrowStyles: {},
attributes: {},
flipped: false,
offsets: {}
};
// compute reference element offsets
data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
// compute auto placement, store placement inside the data object,
// modifiers will be able to edit `placement` if needed
// and refer to originalPlacement to know the original value
data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
// store the computed placement inside `originalPlacement`
data.originalPlacement = data.placement;
data.positionFixed = this.options.positionFixed;
// compute the popper offsets
data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
// run the modifiers
data = runModifiers(this.modifiers, data);
// the first `update` will call `onCreate` callback
// the other ones will call `onUpdate` callback
if (!this.state.isCreated) {
this.state.isCreated = true;
this.options.onCreate(data);
} else {
this.options.onUpdate(data);
}
}
/**
* Helper used to know if the given modifier is enabled.
* @method
* @memberof Popper.Utils
* @returns {Boolean}
*/
function isModifierEnabled(modifiers, modifierName) {
return modifiers.some(function (_ref) {
var name = _ref.name,
enabled = _ref.enabled;
return enabled && name === modifierName;
});
}
/**
* Get the prefixed supported property name
* @method
* @memberof Popper.Utils
* @argument {String} property (camelCase)
* @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
*/
function getSupportedPropertyName(property) {
var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
for (var i = 0; i < prefixes.length; i++) {
var prefix = prefixes[i];
var toCheck = prefix ? '' + prefix + upperProp : property;
if (typeof document.body.style[toCheck] !== 'undefined') {
return toCheck;
}
}
return null;
}
/**
* Destroys the popper.
* @method
* @memberof Popper
*/
function destroy() {
this.state.isDestroyed = true;
// touch DOM only if `applyStyle` modifier is enabled
if (isModifierEnabled(this.modifiers, 'applyStyle')) {
this.popper.removeAttribute('x-placement');
this.popper.style.position = '';
this.popper.style.top = '';
this.popper.style.left = '';
this.popper.style.right = '';
this.popper.style.bottom = '';
this.popper.style.willChange = '';
this.popper.style[getSupportedPropertyName('transform')] = '';
}
this.disableEventListeners();
// remove the popper if user explicitly asked for the deletion on destroy
// do not use `remove` because IE11 doesn't support it
if (this.options.removeOnDestroy) {
this.popper.parentNode.removeChild(this.popper);
}
return this;
}
/**
* Get the window associated with the element
* @argument {Element} element
* @returns {Window}
*/
function getWindow(element) {
var ownerDocument = element.ownerDocument;
return ownerDocument ? ownerDocument.defaultView : window;
}
function attachToScrollParents(scrollParent, event, callback, scrollParents) {
var isBody = scrollParent.nodeName === 'BODY';
var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
target.addEventListener(event, callback, { passive: true });
if (!isBody) {
attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
}
scrollParents.push(target);
}
/**
* Setup needed event listeners used to update the popper position
* @method
* @memberof Popper.Utils
* @private
*/
function setupEventListeners(reference, options, state, updateBound) {
// Resize event listener on window
state.updateBound = updateBound;
getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
// Scroll event listener on scroll parents
var scrollElement = getScrollParent(reference);
attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
state.scrollElement = scrollElement;
state.eventsEnabled = true;
return state;
}
/**
* It will add resize/scroll events and start recalculating
* position of the popper element when they are triggered.
* @method
* @memberof Popper
*/
function enableEventListeners() {
if (!this.state.eventsEnabled) {
this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
}
}
/**
* Remove event listeners used to update the popper position
* @method
* @memberof Popper.Utils
* @private
*/
function removeEventListeners(reference, state) {
// Remove resize event listener on window
getWindow(reference).removeEventListener('resize', state.updateBound);
// Remove scroll event listener on scroll parents
state.scrollParents.forEach(function (target) {
target.removeEventListener('scroll', state.updateBound);
});
// Reset state
state.updateBound = null;
state.scrollParents = [];
state.scrollElement = null;
state.eventsEnabled = false;
return state;
}
/**
* It will remove resize/scroll events and won't recalculate popper position
* when they are triggered. It also won't trigger `onUpdate` callback anymore,
* unless you call `update` method manually.
* @method
* @memberof Popper
*/
function disableEventListeners() {
if (this.state.eventsEnabled) {
cancelAnimationFrame(this.scheduleUpdate);
this.state = removeEventListeners(this.reference, this.state);
}
}
/**
* Tells if a given input is a number
* @method
* @memberof Popper.Utils
* @param {*} input to check
* @return {Boolean}
*/
function isNumeric(n) {
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
}
/**
* Set the style to the given popper
* @method
* @memberof Popper.Utils
* @argument {Element} element - Element to apply the style to
* @argument {Object} styles
* Object with a list of properties and values which will be applied to the element
*/
function setStyles(element, styles) {
Object.keys(styles).forEach(function (prop) {
var unit = '';
// add unit if the value is numeric and is one of the following
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
unit = 'px';
}
element.style[prop] = styles[prop] + unit;
});
}
/**
* Set the attributes to the given popper
* @method
* @memberof Popper.Utils
* @argument {Element} element - Element to apply the attributes to
* @argument {Object} styles
* Object with a list of properties and values which will be applied to the element
*/
function setAttributes(element, attributes) {
Object.keys(attributes).forEach(function (prop) {
var value = attributes[prop];
if (value !== false) {
element.setAttribute(prop, attributes[prop]);
} else {
element.removeAttribute(prop);
}
});
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by `update` method
* @argument {Object} data.styles - List of style properties - values to apply to popper element
* @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The same data object
*/
function applyStyle(data) {
// any property present in `data.styles` will be applied to the popper,
// in this way we can make the 3rd party modifiers add custom styles to it
// Be aware, modifiers could override the properties defined in the previous
// lines of this modifier!
setStyles(data.instance.popper, data.styles);
// any property present in `data.attributes` will be applied to the popper,
// they will be set as HTML attributes of the element
setAttributes(data.instance.popper, data.attributes);
// if arrowElement is defined and arrowStyles has some properties
if (data.arrowElement && Object.keys(data.arrowStyles).length) {
setStyles(data.arrowElement, data.arrowStyles);
}
return data;
}
/**
* Set the x-placement attribute before everything else because it could be used
* to add margins to the popper margins needs to be calculated to get the
* correct popper offsets.
* @method
* @memberof Popper.modifiers
* @param {HTMLElement} reference - The reference element used to position the popper
* @param {HTMLElement} popper - The HTML element used as popper
* @param {Object} options - Popper.js options
*/
function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
// compute reference element offsets
var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
// compute auto placement, store placement inside the data object,
// modifiers will be able to edit `placement` if needed
// and refer to originalPlacement to know the original value
var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
popper.setAttribute('x-placement', placement);
// Apply `position` to popper before anything else because
// without the position applied we can't guarantee correct computations
setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
return options;
}
/**
* @function
* @memberof Popper.Utils
* @argument {Object} data - The data object generated by `update` method
* @argument {Boolean} shouldRound - If the offsets should be rounded at all
* @returns {Object} The popper's position offsets rounded
*
* The tale of pixel-perfect positioning. It's still not 100% perfect, but as
* good as it can be within reason.
* Discussion here: https://github.com/FezVrasta/popper.js/pull/715
*
* Low DPI screens cause a popper to be blurry if not using full pixels (Safari
* as well on High DPI screens).
*
* Firefox prefers no rounding for positioning and does not have blurriness on
* high DPI screens.
*
* Only horizontal placement and left/right values need to be considered.
*/
function getRoundedOffsets(data, shouldRound) {
var _data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var round = Math.round,
floor = Math.floor;
var noRound = function noRound(v) {
return v;
};
var referenceWidth = round(reference.width);
var popperWidth = round(popper.width);
var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
var isVariation = data.placement.indexOf('-') !== -1;
var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
var verticalToInteger = !shouldRound ? noRound : round;
return {
left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
top: verticalToInteger(popper.top),
bottom: verticalToInteger(popper.bottom),
right: horizontalToInteger(popper.right)
};
}
var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by `update` method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function computeStyle(data, options) {
var x = options.x,
y = options.y;
var popper = data.offsets.popper;
// Remove this legacy support in Popper.js v2
var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
return modifier.name === 'applyStyle';
}).gpuAcceleration;
if (legacyGpuAccelerationOption !== undefined) {
console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
}
var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
var offsetParent = getOffsetParent(data.instance.popper);
var offsetParentRect = getBoundingClientRect(offsetParent);
// Styles
var styles = {
position: popper.position
};
var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
var sideA = x === 'bottom' ? 'top' : 'bottom';
var sideB = y === 'right' ? 'left' : 'right';
// if gpuAcceleration is set to `true` and transform is supported,
// we use `translate3d` to apply the position to the popper we
// automatically use the supported prefixed version if needed
var prefixedProperty = getSupportedPropertyName('transform');
// now, let's make a step back and look at this code closely (wtf?)
// If the content of the popper grows once it's been positioned, it
// may happen that the popper gets misplaced because of the new content
// overflowing its reference element
// To avoid this problem, we provide two options (x and y), which allow
// the consumer to define the offset origin.
// If we position a popper on top of a reference element, we can set
// `x` to `top` to make the popper grow towards its top instead of
// its bottom.
var left = void 0,
top = void 0;
if (sideA === 'bottom') {
// when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
// and not the bottom of the html element
if (offsetParent.nodeName === 'HTML') {
top = -offsetParent.clientHeight + offsets.bottom;
} else {
top = -offsetParentRect.height + offsets.bottom;
}
} else {
top = offsets.top;
}
if (sideB === 'right') {
if (offsetParent.nodeName === 'HTML') {
left = -offsetParent.clientWidth + offsets.right;
} else {
left = -offsetParentRect.width + offsets.right;
}
} else {
left = offsets.left;
}
if (gpuAcceleration && prefixedProperty) {
styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
styles[sideA] = 0;
styles[sideB] = 0;
styles.willChange = 'transform';
} else {
// othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
var invertTop = sideA === 'bottom' ? -1 : 1;
var invertLeft = sideB === 'right' ? -1 : 1;
styles[sideA] = top * invertTop;
styles[sideB] = left * invertLeft;
styles.willChange = sideA + ', ' + sideB;
}
// Attributes
var attributes = {
'x-placement': data.placement
};
// Update `data` attributes, styles and arrowStyles
data.attributes = _extends({}, attributes, data.attributes);
data.styles = _extends({}, styles, data.styles);
data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
return data;
}
/**
* Helper used to know if the given modifier depends from another one.<br />
* It checks if the needed modifier is listed and enabled.
* @method
* @memberof Popper.Utils
* @param {Array} modifiers - list of modifiers
* @param {String} requestingName - name of requesting modifier
* @param {String} requestedName - name of requested modifier
* @returns {Boolean}
*/
function isModifierRequired(modifiers, requestingName, requestedName) {
var requesting = find(modifiers, function (_ref) {
var name = _ref.name;
return name === requestingName;
});
var isRequired = !!requesting && modifiers.some(function (modifier) {
return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
});
if (!isRequired) {
var _requesting = '`' + requestingName + '`';
var requested = '`' + requestedName + '`';
console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
}
return isRequired;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function arrow(data, options) {
var _data$offsets$arrow;
// arrow depends on keepTogether in order to work
if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
return data;
}
var arrowElement = options.element;
// if arrowElement is a string, suppose it's a CSS selector
if (typeof arrowElement === 'string') {
arrowElement = data.instance.popper.querySelector(arrowElement);
// if arrowElement is not found, don't run the modifier
if (!arrowElement) {
return data;
}
} else {
// if the arrowElement isn't a query selector we must check that the
// provided DOM node is child of its popper node
if (!data.instance.popper.contains(arrowElement)) {
console.warn('WARNING: `arrow.element` must be child of its popper element!');
return data;
}
}
var placement = data.placement.split('-')[0];
var _data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var isVertical = ['left', 'right'].indexOf(placement) !== -1;
var len = isVertical ? 'height' : 'width';
var sideCapitalized = isVertical ? 'Top' : 'Left';
var side = sideCapitalized.toLowerCase();
var altSide = isVertical ? 'left' : 'top';
var opSide = isVertical ? 'bottom' : 'right';
var arrowElementSize = getOuterSizes(arrowElement)[len];
//
// extends keepTogether behavior making sure the popper and its
// reference have enough pixels in conjunction
//
// top/left side
if (reference[opSide] - arrowElementSize < popper[side]) {
data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
}
// bottom/right side
if (reference[side] + arrowElementSize > popper[opSide]) {
data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
}
data.offsets.popper = getClientRect(data.offsets.popper);
// compute center of the popper
var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
// Compute the sideValue using the updated popper offsets
// take popper margin in account because we don't have this info available
var css = getStyleComputedProperty(data.instance.popper);
var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
// prevent arrowElement from being placed not contiguously to its popper
sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
data.arrowElement = arrowElement;
data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
return data;
}
/**
* Get the opposite placement variation of the given one
* @method
* @memberof Popper.Utils
* @argument {String} placement variation
* @returns {String} flipped placement variation
*/
function getOppositeVariation(variation) {
if (variation === 'end') {
return 'start';
} else if (variation === 'start') {
return 'end';
}
return variation;
}
/**
* List of accepted placements to use as values of the `placement` option.<br />
* Valid placements are:
* - `auto`
* - `top`
* - `right`
* - `bottom`
* - `left`
*
* Each placement can have a variation from this list:
* - `-start`
* - `-end`
*
* Variations are interpreted easily if you think of them as the left to right
* written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
* is right.<br />
* Vertically (`left` and `right`), `start` is top and `end` is bottom.
*
* Some valid examples are:
* - `top-end` (on top of reference, right aligned)
* - `right-start` (on right of reference, top aligned)
* - `bottom` (on bottom, centered)
* - `auto-end` (on the side with more space available, alignment depends by placement)
*
* @static
* @type {Array}
* @enum {String}
* @readonly
* @method placements
* @memberof Popper
*/
var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
// Get rid of `auto` `auto-start` and `auto-end`
var validPlacements = placements.slice(3);
/**
* Given an initial placement, returns all the subsequent placements
* clockwise (or counter-clockwise).
*
* @method
* @memberof Popper.Utils
* @argument {String} placement - A valid placement (it accepts variations)
* @argument {Boolean} counter - Set to true to walk the placements counterclockwise
* @returns {Array} placements including their variations
*/
function clockwise(placement) {
var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var index = validPlacements.indexOf(placement);
var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
return counter ? arr.reverse() : arr;
}
var BEHAVIORS = {
FLIP: 'flip',
CLOCKWISE: 'clockwise',
COUNTERCLOCKWISE: 'counterclockwise'
};
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function flip(data, options) {
// if `inner` modifier is enabled, we can't use the `flip` modifier
if (isModifierEnabled(data.instance.modifiers, 'inner')) {
return data;
}
if (data.flipped && data.placement === data.originalPlacement) {
// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
return data;
}
var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
var placement = data.placement.split('-')[0];
var placementOpposite = getOppositePlacement(placement);
var variation = data.placement.split('-')[1] || '';
var flipOrder = [];
switch (options.behavior) {
case BEHAVIORS.FLIP:
flipOrder = [placement, placementOpposite];
break;
case BEHAVIORS.CLOCKWISE:
flipOrder = clockwise(placement);
break;
case BEHAVIORS.COUNTERCLOCKWISE:
flipOrder = clockwise(placement, true);
break;
default:
flipOrder = options.behavior;
}
flipOrder.forEach(function (step, index) {
if (placement !== step || flipOrder.length === index + 1) {
return data;
}
placement = data.placement.split('-')[0];
placementOpposite = getOppositePlacement(placement);
var popperOffsets = data.offsets.popper;
var refOffsets = data.offsets.reference;
// using floor because the reference offsets may contain decimals we are not going to consider here
var floor = Math.floor;
var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
// flip the variation if required
var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
// flips variation if reference element overflows boundaries
var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
// flips variation if popper content overflows boundaries
var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
var flippedVariation = flippedVariationByRef || flippedVariationByContent;
if (overlapsRef || overflowsBoundaries || flippedVariation) {
// this boolean to detect any flip loop
data.flipped = true;
if (overlapsRef || overflowsBoundaries) {
placement = flipOrder[index + 1];
}
if (flippedVariation) {
variation = getOppositeVariation(variation);
}
data.placement = placement + (variation ? '-' + variation : '');
// this object contains `position`, we want to preserve it along with
// any additional property we may add in the future
data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
data = runModifiers(data.instance.modifiers, data, 'flip');
}
});
return data;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function keepTogether(data) {
var _data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var placement = data.placement.split('-')[0];
var floor = Math.floor;
var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
var side = isVertical ? 'right' : 'bottom';
var opSide = isVertical ? 'left' : 'top';
var measurement = isVertical ? 'width' : 'height';
if (popper[side] < floor(reference[opSide])) {
data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
}
if (popper[opSide] > floor(reference[side])) {
data.offsets.popper[opSide] = floor(reference[side]);
}
return data;
}
/**
* Converts a string containing value + unit into a px value number
* @function
* @memberof {modifiers~offset}
* @private
* @argument {String} str - Value + unit string
* @argument {String} measurement - `height` or `width`
* @argument {Object} popperOffsets
* @argument {Object} referenceOffsets
* @returns {Number|String}
* Value in pixels, or original string if no values were extracted
*/
function toValue(str, measurement, popperOffsets, referenceOffsets) {
// separate value from unit
var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
var value = +split[1];
var unit = split[2];
// If it's not a number it's an operator, I guess
if (!value) {
return str;
}
if (unit.indexOf('%') === 0) {
var element = void 0;
switch (unit) {
case '%p':
element = popperOffsets;
break;
case '%':
case '%r':
default:
element = referenceOffsets;
}
var rect = getClientRect(element);
return rect[measurement] / 100 * value;
} else if (unit === 'vh' || unit === 'vw') {
// if is a vh or vw, we calculate the size based on the viewport
var size = void 0;
if (unit === 'vh') {
size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
} else {
size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
}
return size / 100 * value;
} else {
// if is an explicit pixel unit, we get rid of the unit and keep the value
// if is an implicit unit, it's px, and we return just the value
return value;
}
}
/**
* Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
* @function
* @memberof {modifiers~offset}
* @private
* @argument {String} offset
* @argument {Object} popperOffsets
* @argument {Object} referenceOffsets
* @argument {String} basePlacement
* @returns {Array} a two cells array with x and y offsets in numbers
*/
function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
var offsets = [0, 0];
// Use height if placement is left or right and index is 0 otherwise use width
// in this way the first offset will use an axis and the second one
// will use the other one
var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
// Split the offset string to obtain a list of values and operands
// The regex addresses values with the plus or minus sign in front (+10, -20, etc)
var fragments = offset.split(/(\+|\-)/).map(function (frag) {
return frag.trim();
});
// Detect if the offset string contains a pair of values or a single one
// they could be separated by comma or space
var divider = fragments.indexOf(find(fragments, function (frag) {
return frag.search(/,|\s/) !== -1;
}));
if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
}
// If divider is found, we divide the list of values and operands to divide
// them by ofset X and Y.
var splitRegex = /\s*,\s*|\s+/;
var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
// Convert the values with units to absolute pixels to allow our computations
ops = ops.map(function (op, index) {
// Most of the units rely on the orientation of the popper
var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
var mergeWithPrevious = false;
return op
// This aggregates any `+` or `-` sign that aren't considered operators
// e.g.: 10 + +5 => [10, +, +5]
.reduce(function (a, b) {
if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
a[a.length - 1] = b;
mergeWithPrevious = true;
return a;
} else if (mergeWithPrevious) {
a[a.length - 1] += b;
mergeWithPrevious = false;
return a;
} else {
return a.concat(b);
}
}, [])
// Here we convert the string values into number values (in px)
.map(function (str) {
return toValue(str, measurement, popperOffsets, referenceOffsets);
});
});
// Loop trough the offsets arrays and execute the operations
ops.forEach(function (op, index) {
op.forEach(function (frag, index2) {
if (isNumeric(frag)) {
offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
}
});
});
return offsets;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @argument {Number|String} options.offset=0
* The offset value as described in the modifier description
* @returns {Object} The data object, properly modified
*/
function offset(data, _ref) {
var offset = _ref.offset;
var placement = data.placement,
_data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var basePlacement = placement.split('-')[0];
var offsets = void 0;
if (isNumeric(+offset)) {
offsets = [+offset, 0];
} else {
offsets = parseOffset(offset, popper, reference, basePlacement);
}
if (basePlacement === 'left') {
popper.top += offsets[0];
popper.left -= offsets[1];
} else if (basePlacement === 'right') {
popper.top += offsets[0];
popper.left += offsets[1];
} else if (basePlacement === 'top') {
popper.left += offsets[0];
popper.top -= offsets[1];
} else if (basePlacement === 'bottom') {
popper.left += offsets[0];
popper.top += offsets[1];
}
data.popper = popper;
return data;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by `update` method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function preventOverflow(data, options) {
var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
// If offsetParent is the reference element, we really want to
// go one step up and use the next offsetParent as reference to
// avoid to make this modifier completely useless and look like broken
if (data.instance.reference === boundariesElement) {
boundariesElement = getOffsetParent(boundariesElement);
}
// NOTE: DOM access here
// resets the popper's position so that the document size can be calculated excluding
// the size of the popper element itself
var transformProp = getSupportedPropertyName('transform');
var popperStyles = data.instance.popper.style; // assignment to help minification
var top = popperStyles.top,
left = popperStyles.left,
transform = popperStyles[transformProp];
popperStyles.top = '';
popperStyles.left = '';
popperStyles[transformProp] = '';
var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
// NOTE: DOM access here
// restores the original style properties after the offsets have been computed
popperStyles.top = top;
popperStyles.left = left;
popperStyles[transformProp] = transform;
options.boundaries = boundaries;
var order = options.priority;
var popper = data.offsets.popper;
var check = {
primary: function primary(placement) {
var value = popper[placement];
if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
value = Math.max(popper[placement], boundaries[placement]);
}
return defineProperty({}, placement, value);
},
secondary: function secondary(placement) {
var mainSide = placement === 'right' ? 'left' : 'top';
var value = popper[mainSide];
if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
}
return defineProperty({}, mainSide, value);
}
};
order.forEach(function (placement) {
var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
popper = _extends({}, popper, check[side](placement));
});
data.offsets.popper = popper;
return data;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by `update` method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function shift(data) {
var placement = data.placement;
var basePlacement = placement.split('-')[0];
var shiftvariation = placement.split('-')[1];
// if shift shiftvariation is specified, run the modifier
if (shiftvariation) {
var _data$offsets = data.offsets,
reference = _data$offsets.reference,
popper = _data$offsets.popper;
var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
var side = isVertical ? 'left' : 'top';
var measurement = isVertical ? 'width' : 'height';
var shiftOffsets = {
start: defineProperty({}, side, reference[side]),
end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
};
data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
}
return data;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by update method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function hide(data) {
if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
return data;
}
var refRect = data.offsets.reference;
var bound = find(data.instance.modifiers, function (modifier) {
return modifier.name === 'preventOverflow';
}).boundaries;
if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
// Avoid unnecessary DOM access if visibility hasn't changed
if (data.hide === true) {
return data;
}
data.hide = true;
data.attributes['x-out-of-boundaries'] = '';
} else {
// Avoid unnecessary DOM access if visibility hasn't changed
if (data.hide === false) {
return data;
}
data.hide = false;
data.attributes['x-out-of-boundaries'] = false;
}
return data;
}
/**
* @function
* @memberof Modifiers
* @argument {Object} data - The data object generated by `update` method
* @argument {Object} options - Modifiers configuration and options
* @returns {Object} The data object, properly modified
*/
function inner(data) {
var placement = data.placement;
var basePlacement = placement.split('-')[0];
var _data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
data.placement = getOppositePlacement(placement);
data.offsets.popper = getClientRect(popper);
return data;
}
/**
* Modifier function, each modifier can have a function of this type assigned
* to its `fn` property.<br />
* These functions will be called on each update, this means that you must
* make sure they are performant enough to avoid performance bottlenecks.
*
* @function ModifierFn
* @argument {dataObject} data - The data object generated by `update` method
* @argument {Object} options - Modifiers configuration and options
* @returns {dataObject} The data object, properly modified
*/
/**
* Modifiers are plugins used to alter the behavior of your poppers.<br />
* Popper.js uses a set of 9 modifiers to provide all the basic functionalities
* needed by the library.
*
* Usually you don't want to override the `order`, `fn` and `onLoad` props.
* All the other properties are configurations that could be tweaked.
* @namespace modifiers
*/
var modifiers = {
/**
* Modifier used to shift the popper on the start or end of its reference
* element.<br />
* It will read the variation of the `placement` property.<br />
* It can be one either `-end` or `-start`.
* @memberof modifiers
* @inner
*/
shift: {
/** @prop {number} order=100 - Index used to define the order of execution */
order: 100,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: shift
},
/**
* The `offset` modifier can shift your popper on both its axis.
*
* It accepts the following units:
* - `px` or unit-less, interpreted as pixels
* - `%` or `%r`, percentage relative to the length of the reference element
* - `%p`, percentage relative to the length of the popper element
* - `vw`, CSS viewport width unit
* - `vh`, CSS viewport height unit
*
* For length is intended the main axis relative to the placement of the popper.<br />
* This means that if the placement is `top` or `bottom`, the length will be the
* `width`. In case of `left` or `right`, it will be the `height`.
*
* You can provide a single value (as `Number` or `String`), or a pair of values
* as `String` divided by a comma or one (or more) white spaces.<br />
* The latter is a deprecated method because it leads to confusion and will be
* removed in v2.<br />
* Additionally, it accepts additions and subtractions between different units.
* Note that multiplications and divisions aren't supported.
*
* Valid examples are:
* ```
* 10
* '10%'
* '10, 10'
* '10%, 10'
* '10 + 10%'
* '10 - 5vh + 3%'
* '-10px + 5vh, 5px - 6%'
* ```
* > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
* > with their reference element, unfortunately, you will have to disable the `flip` modifier.
* > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
*
* @memberof modifiers
* @inner
*/
offset: {
/** @prop {number} order=200 - Index used to define the order of execution */
order: 200,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: offset,
/** @prop {Number|String} offset=0
* The offset value as described in the modifier description
*/
offset: 0
},
/**
* Modifier used to prevent the popper from being positioned outside the boundary.
*
* A scenario exists where the reference itself is not within the boundaries.<br />
* We can say it has "escaped the boundaries" — or just "escaped".<br />
* In this case we need to decide whether the popper should either:
*
* - detach from the reference and remain "trapped" in the boundaries, or
* - if it should ignore the boundary and "escape with its reference"
*
* When `escapeWithReference` is set to`true` and reference is completely
* outside its boundaries, the popper will overflow (or completely leave)
* the boundaries in order to remain attached to the edge of the reference.
*
* @memberof modifiers
* @inner
*/
preventOverflow: {
/** @prop {number} order=300 - Index used to define the order of execution */
order: 300,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: preventOverflow,
/**
* @prop {Array} [priority=['left','right','top','bottom']]
* Popper will try to prevent overflow following these priorities by default,
* then, it could overflow on the left and on top of the `boundariesElement`
*/
priority: ['left', 'right', 'top', 'bottom'],
/**
* @prop {number} padding=5
* Amount of pixel used to define a minimum distance between the boundaries
* and the popper. This makes sure the popper always has a little padding
* between the edges of its container
*/
padding: 5,
/**
* @prop {String|HTMLElement} boundariesElement='scrollParent'
* Boundaries used by the modifier. Can be `scrollParent`, `window`,
* `viewport` or any DOM element.
*/
boundariesElement: 'scrollParent'
},
/**
* Modifier used to make sure the reference and its popper stay near each other
* without leaving any gap between the two. Especially useful when the arrow is
* enabled and you want to ensure that it points to its reference element.
* It cares only about the first axis. You can still have poppers with margin
* between the popper and its reference element.
* @memberof modifiers
* @inner
*/
keepTogether: {
/** @prop {number} order=400 - Index used to define the order of execution */
order: 400,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: keepTogether
},
/**
* This modifier is used to move the `arrowElement` of the popper to make
* sure it is positioned between the reference element and its popper element.
* It will read the outer size of the `arrowElement` node to detect how many
* pixels of conjunction are needed.
*
* It has no effect if no `arrowElement` is provided.
* @memberof modifiers
* @inner
*/
arrow: {
/** @prop {number} order=500 - Index used to define the order of execution */
order: 500,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: arrow,
/** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
element: '[x-arrow]'
},
/**
* Modifier used to flip the popper's placement when it starts to overlap its
* reference element.
*
* Requires the `preventOverflow` modifier before it in order to work.
*
* **NOTE:** this modifier will interrupt the current update cycle and will
* restart it if it detects the need to flip the placement.
* @memberof modifiers
* @inner
*/
flip: {
/** @prop {number} order=600 - Index used to define the order of execution */
order: 600,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: flip,
/**
* @prop {String|Array} behavior='flip'
* The behavior used to change the popper's placement. It can be one of
* `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
* placements (with optional variations)
*/
behavior: 'flip',
/**
* @prop {number} padding=5
* The popper will flip if it hits the edges of the `boundariesElement`
*/
padding: 5,
/**
* @prop {String|HTMLElement} boundariesElement='viewport'
* The element which will define the boundaries of the popper position.
* The popper will never be placed outside of the defined boundaries
* (except if `keepTogether` is enabled)
*/
boundariesElement: 'viewport',
/**
* @prop {Boolean} flipVariations=false
* The popper will switch placement variation between `-start` and `-end` when
* the reference element overlaps its boundaries.
*
* The original placement should have a set variation.
*/
flipVariations: false,
/**
* @prop {Boolean} flipVariationsByContent=false
* The popper will switch placement variation between `-start` and `-end` when
* the popper element overlaps its reference boundaries.
*
* The original placement should have a set variation.
*/
flipVariationsByContent: false
},
/**
* Modifier used to make the popper flow toward the inner of the reference element.
* By default, when this modifier is disabled, the popper will be placed outside
* the reference element.
* @memberof modifiers
* @inner
*/
inner: {
/** @prop {number} order=700 - Index used to define the order of execution */
order: 700,
/** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
enabled: false,
/** @prop {ModifierFn} */
fn: inner
},
/**
* Modifier used to hide the popper when its reference element is outside of the
* popper boundaries. It will set a `x-out-of-boundaries` attribute which can
* be used to hide with a CSS selector the popper when its reference is
* out of boundaries.
*
* Requires the `preventOverflow` modifier before it in order to work.
* @memberof modifiers
* @inner
*/
hide: {
/** @prop {number} order=800 - Index used to define the order of execution */
order: 800,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: hide
},
/**
* Computes the style that will be applied to the popper element to gets
* properly positioned.
*
* Note that this modifier will not touch the DOM, it just prepares the styles
* so that `applyStyle` modifier can apply it. This separation is useful
* in case you need to replace `applyStyle` with a custom implementation.
*
* This modifier has `850` as `order` value to maintain backward compatibility
* with previous versions of Popper.js. Expect the modifiers ordering method
* to change in future major versions of the library.
*
* @memberof modifiers
* @inner
*/
computeStyle: {
/** @prop {number} order=850 - Index used to define the order of execution */
order: 850,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: computeStyle,
/**
* @prop {Boolean} gpuAcceleration=true
* If true, it uses the CSS 3D transformation to position the popper.
* Otherwise, it will use the `top` and `left` properties
*/
gpuAcceleration: true,
/**
* @prop {string} [x='bottom']
* Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
* Change this if your popper should grow in a direction different from `bottom`
*/
x: 'bottom',
/**
* @prop {string} [x='left']
* Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
* Change this if your popper should grow in a direction different from `right`
*/
y: 'right'
},
/**
* Applies the computed styles to the popper element.
*
* All the DOM manipulations are limited to this modifier. This is useful in case
* you want to integrate Popper.js inside a framework or view library and you
* want to delegate all the DOM manipulations to it.
*
* Note that if you disable this modifier, you must make sure the popper element
* has its position set to `absolute` before Popper.js can do its work!
*
* Just disable this modifier and define your own to achieve the desired effect.
*
* @memberof modifiers
* @inner
*/
applyStyle: {
/** @prop {number} order=900 - Index used to define the order of execution */
order: 900,
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
enabled: true,
/** @prop {ModifierFn} */
fn: applyStyle,
/** @prop {Function} */
onLoad: applyStyleOnLoad,
/**
* @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
* @prop {Boolean} gpuAcceleration=true
* If true, it uses the CSS 3D transformation to position the popper.
* Otherwise, it will use the `top` and `left` properties
*/
gpuAcceleration: undefined
}
};
/**
* The `dataObject` is an object containing all the information used by Popper.js.
* This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
* @name dataObject
* @property {Object} data.instance The Popper.js instance
* @property {String} data.placement Placement applied to popper
* @property {String} data.originalPlacement Placement originally defined on init
* @property {Boolean} data.flipped True if popper has been flipped by flip modifier
* @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
* @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
* @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
* @property {Object} data.boundaries Offsets of the popper boundaries
* @property {Object} data.offsets The measurements of popper, reference and arrow elements
* @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
* @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
* @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
*/
/**
* Default options provided to Popper.js constructor.<br />
* These can be overridden using the `options` argument of Popper.js.<br />
* To override an option, simply pass an object with the same
* structure of the `options` object, as the 3rd argument. For example:
* ```
* new Popper(ref, pop, {
* modifiers: {
* preventOverflow: { enabled: false }
* }
* })
* ```
* @type {Object}
* @static
* @memberof Popper
*/
var Defaults = {
/**
* Popper's placement.
* @prop {Popper.placements} placement='bottom'
*/
placement: 'bottom',
/**
* Set this to true if you want popper to position it self in 'fixed' mode
* @prop {Boolean} positionFixed=false
*/
positionFixed: false,
/**
* Whether events (resize, scroll) are initially enabled.
* @prop {Boolean} eventsEnabled=true
*/
eventsEnabled: true,
/**
* Set to true if you want to automatically remove the popper when
* you call the `destroy` method.
* @prop {Boolean} removeOnDestroy=false
*/
removeOnDestroy: false,
/**
* Callback called when the popper is created.<br />
* By default, it is set to no-op.<br />
* Access Popper.js instance with `data.instance`.
* @prop {onCreate}
*/
onCreate: function onCreate() {},
/**
* Callback called when the popper is updated. This callback is not called
* on the initialization/creation of the popper, but only on subsequent
* updates.<br />
* By default, it is set to no-op.<br />
* Access Popper.js instance with `data.instance`.
* @prop {onUpdate}
*/
onUpdate: function onUpdate() {},
/**
* List of modifiers used to modify the offsets before they are applied to the popper.
* They provide most of the functionalities of Popper.js.
* @prop {modifiers}
*/
modifiers: modifiers
};
/**
* @callback onCreate
* @param {dataObject} data
*/
/**
* @callback onUpdate
* @param {dataObject} data
*/
// Utils
// Methods
var Popper = function () {
/**
* Creates a new Popper.js instance.
* @class Popper
* @param {Element|referenceObject} reference - The reference element used to position the popper
* @param {Element} popper - The HTML / XML element used as the popper
* @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
* @return {Object} instance - The generated Popper.js instance
*/
function Popper(reference, popper) {
var _this = this;
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
classCallCheck(this, Popper);
this.scheduleUpdate = function () {
return requestAnimationFrame(_this.update);
};
// make update() debounced, so that it only runs at most once-per-tick
this.update = debounce(this.update.bind(this));
// with {} we create a new object with the options inside it
this.options = _extends({}, Popper.Defaults, options);
// init state
this.state = {
isDestroyed: false,
isCreated: false,
scrollParents: []
};
// get reference and popper elements (allow jQuery wrappers)
this.reference = reference && reference.jquery ? reference[0] : reference;
this.popper = popper && popper.jquery ? popper[0] : popper;
// Deep merge modifiers options
this.options.modifiers = {};
Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
_this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
});
// Refactoring modifiers' list (Object => Array)
this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
return _extends({
name: name
}, _this.options.modifiers[name]);
})
// sort the modifiers by order
.sort(function (a, b) {
return a.order - b.order;
});
// modifiers have the ability to execute arbitrary code when Popper.js get inited
// such code is executed in the same order of its modifier
// they could add new properties to their options configuration
// BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
this.modifiers.forEach(function (modifierOptions) {
if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
}
});
// fire the first update to position the popper in the right place
this.update();
var eventsEnabled = this.options.eventsEnabled;
if (eventsEnabled) {
// setup event listeners, they will take care of update the position in specific situations
this.enableEventListeners();
}
this.state.eventsEnabled = eventsEnabled;
}
// We can't use class properties because they don't get listed in the
// class prototype and break stuff like Sinon stubs
createClass(Popper, [{
key: 'update',
value: function update$$1() {
return update.call(this);
}
}, {
key: 'destroy',
value: function destroy$$1() {
return destroy.call(this);
}
}, {
key: 'enableEventListeners',
value: function enableEventListeners$$1() {
return enableEventListeners.call(this);
}
}, {
key: 'disableEventListeners',
value: function disableEventListeners$$1() {
return disableEventListeners.call(this);
}
/**
* Schedules an update. It will run on the next UI update available.
* @method scheduleUpdate
* @memberof Popper
*/
/**
* Collection of utilities useful when writing custom modifiers.
* Starting from version 1.7, this method is available only if you
* include `popper-utils.js` before `popper.js`.
*
* **DEPRECATION**: This way to access PopperUtils is deprecated
* and will be removed in v2! Use the PopperUtils module directly instead.
* Due to the high instability of the methods contained in Utils, we can't
* guarantee them to follow semver. Use them at your own risk!
* @static
* @private
* @type {Object}
* @deprecated since version 1.8
* @member Utils
* @memberof Popper
*/
}]);
return Popper;
}();
/**
* The `referenceObject` is an object that provides an interface compatible with Popper.js
* and lets you use it as replacement of a real DOM node.<br />
* You can use this method to position a popper relatively to a set of coordinates
* in case you don't have a DOM node to use as reference.
*
* ```
* new Popper(referenceObject, popperNode);
* ```
*
* NB: This feature isn't supported in Internet Explorer 10.
* @name referenceObject
* @property {Function} data.getBoundingClientRect
* A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
* @property {number} data.clientWidth
* An ES6 getter that will return the width of the virtual reference element.
* @property {number} data.clientHeight
* An ES6 getter that will return the height of the virtual reference element.
*/
Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
Popper.placements = placements;
Popper.Defaults = Defaults;
/* harmony default export */ __webpack_exports__["default"] = (Popper);
//# sourceMappingURL=popper.js.map
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(4)))
/***/ }),
/* 4 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* Bootstrap-select v1.13.12 (https://developer.snapappointments.com/bootstrap-select)
*
* Copyright 2012-2019 SnapAppointments, LLC
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
*/
(function (root, factory) {
if (root === undefined && window !== undefined) root = window;
if (true) {
// AMD. Register as an anonymous module unless amdModuleId is set
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(0)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (a0) {
return (factory(a0));
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"));
} else {
factory(root["jQuery"]);
}
}(this, function (jQuery) {
(function ($) {
'use strict';
var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
var uriAttrs = [
'background',
'cite',
'href',
'itemtype',
'longdesc',
'poster',
'src',
'xlink:href'
];
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
var DefaultWhitelist = {
// Global attributes allowed on any supplied element below.
'*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN],
a: ['target', 'href', 'title', 'rel'],
area: [],
b: [],
br: [],
col: [],
code: [],
div: [],
em: [],
hr: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
i: [],
img: ['src', 'alt', 'title', 'width', 'height'],
li: [],
ol: [],
p: [],
pre: [],
s: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
u: [],
ul: []
}
/**
* A pattern that recognizes a commonly useful subset of URLs that are safe.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio types.
*
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
*/
var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
function allowedAttribute (attr, allowedAttributeList) {
var attrName = attr.nodeName.toLowerCase()
if ($.inArray(attrName, allowedAttributeList) !== -1) {
if ($.inArray(attrName, uriAttrs) !== -1) {
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
}
return true
}
var regExp = $(allowedAttributeList).filter(function (index, value) {
return value instanceof RegExp
})
// Check if a regular expression validates the attribute.
for (var i = 0, l = regExp.length; i < l; i++) {
if (attrName.match(regExp[i])) {
return true
}
}
return false
}
function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) {
if (sanitizeFn && typeof sanitizeFn === 'function') {
return sanitizeFn(unsafeElements);
}
var whitelistKeys = Object.keys(whiteList);
for (var i = 0, len = unsafeElements.length; i < len; i++) {
var elements = unsafeElements[i].querySelectorAll('*');
for (var j = 0, len2 = elements.length; j < len2; j++) {
var el = elements[j];
var elName = el.nodeName.toLowerCase();
if (whitelistKeys.indexOf(elName) === -1) {
el.parentNode.removeChild(el);
continue;
}
var attributeList = [].slice.call(el.attributes);
var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
for (var k = 0, len3 = attributeList.length; k < len3; k++) {
var attr = attributeList[k];
if (!allowedAttribute(attr, whitelistedAttributes)) {
el.removeAttribute(attr.nodeName);
}
}
}
}
}
// Polyfill for browsers with no classList support
// Remove in v2
if (!('classList' in document.createElement('_'))) {
(function (view) {
if (!('Element' in view)) return;
var classListProp = 'classList',
protoProp = 'prototype',
elemCtrProto = view.Element[protoProp],
objCtr = Object,
classListGetter = function () {
var $elem = $(this);
return {
add: function (classes) {
classes = Array.prototype.slice.call(arguments).join(' ');
return $elem.addClass(classes);
},
remove: function (classes) {
classes = Array.prototype.slice.call(arguments).join(' ');
return $elem.removeClass(classes);
},
toggle: function (classes, force) {
return $elem.toggleClass(classes, force);
},
contains: function (classes) {
return $elem.hasClass(classes);
}
}
};
if (objCtr.defineProperty) {
var classListPropDesc = {
get: classListGetter,
enumerable: true,
configurable: true
};
try {
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
} catch (ex) { // IE 8 doesn't support enumerable:true
// adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
// modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
if (ex.number === undefined || ex.number === -0x7FF5EC54) {
classListPropDesc.enumerable = false;
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
}
}
} else if (objCtr[protoProp].__defineGetter__) {
elemCtrProto.__defineGetter__(classListProp, classListGetter);
}
}(window));
}
var testElement = document.createElement('_');
testElement.classList.add('c1', 'c2');
if (!testElement.classList.contains('c2')) {
var _add = DOMTokenList.prototype.add,
_remove = DOMTokenList.prototype.remove;
DOMTokenList.prototype.add = function () {
Array.prototype.forEach.call(arguments, _add.bind(this));
}
DOMTokenList.prototype.remove = function () {
Array.prototype.forEach.call(arguments, _remove.bind(this));
}
}
testElement.classList.toggle('c3', false);
// Polyfill for IE 10 and Firefox <24, where classList.toggle does not
// support the second argument.
if (testElement.classList.contains('c3')) {
var _toggle = DOMTokenList.prototype.toggle;
DOMTokenList.prototype.toggle = function (token, force) {
if (1 in arguments && !this.contains(token) === !force) {
return force;
} else {
return _toggle.call(this, token);
}
};
}
testElement = null;
// shallow array comparison
function isEqual (array1, array2) {
return array1.length === array2.length && array1.every(function (element, index) {
return element === array2[index];
});
};
// <editor-fold desc="Shims">
if (!String.prototype.startsWith) {
(function () {
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
var defineProperty = (function () {
// IE 8 only supports `Object.defineProperty` on DOM elements
try {
var object = {};
var $defineProperty = Object.defineProperty;
var result = $defineProperty(object, object, object) && $defineProperty;
} catch (error) {
}
return result;
}());
var toString = {}.toString;
var startsWith = function (search) {
if (this == null) {
throw new TypeError();
}
var string = String(this);
if (search && toString.call(search) == '[object RegExp]') {
throw new TypeError();
}
var stringLength = string.length;
var searchString = String(search);
var searchLength = searchString.length;
var position = arguments.length > 1 ? arguments[1] : undefined;
// `ToInteger`
var pos = position ? Number(position) : 0;
if (pos != pos) { // better `isNaN`
pos = 0;
}
var start = Math.min(Math.max(pos, 0), stringLength);
// Avoid the `indexOf` call if no match is possible
if (searchLength + start > stringLength) {
return false;
}
var index = -1;
while (++index < searchLength) {
if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
return false;
}
}
return true;
};
if (defineProperty) {
defineProperty(String.prototype, 'startsWith', {
'value': startsWith,
'configurable': true,
'writable': true
});
} else {
String.prototype.startsWith = startsWith;
}
}());
}
if (!Object.keys) {
Object.keys = function (
o, // object
k, // key
r // result array
) {
// initialize object and result
r = [];
// iterate over object keys
for (k in o) {
// fill result array with non-prototypical keys
r.hasOwnProperty.call(o, k) && r.push(k);
}
// return result
return r;
};
}
if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) {
Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', {
get: function () {
return this.querySelectorAll(':checked');
}
});
}
function getSelectedOptions (select, ignoreDisabled) {
var selectedOptions = select.selectedOptions,
options = [],
opt;
if (ignoreDisabled) {
for (var i = 0, len = selectedOptions.length; i < len; i++) {
opt = selectedOptions[i];
if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
options.push(opt);
}
}
return options;
}
return selectedOptions;
}
// much faster than $.val()
function getSelectValues (select, selectedOptions) {
var value = [],
options = selectedOptions || select.selectedOptions,
opt;
for (var i = 0, len = options.length; i < len; i++) {
opt = options[i];
if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
value.push(opt.value || opt.text);
}
}
if (!select.multiple) {
return !value.length ? null : value[0];
}
return value;
}
// set data-selected on select element if the value has been programmatically selected
// prior to initialization of bootstrap-select
// * consider removing or replacing an alternative method *
var valHooks = {
useDefault: false,
_set: $.valHooks.select.set
};
$.valHooks.select.set = function (elem, value) {
if (value && !valHooks.useDefault) $(elem).data('selected', true);
return valHooks._set.apply(this, arguments);
};
var changedArguments = null;
var EventIsSupported = (function () {
try {
new Event('change');
return true;
} catch (e) {
return false;
}
})();
$.fn.triggerNative = function (eventName) {
var el = this[0],
event;
if (el.dispatchEvent) { // for modern browsers & IE9+
if (EventIsSupported) {
// For modern browsers
event = new Event(eventName, {
bubbles: true
});
} else {
// For IE since it doesn't support Event constructor
event = document.createEvent('Event');
event.initEvent(eventName, true, false);
}
el.dispatchEvent(event);
} else if (el.fireEvent) { // for IE8
event = document.createEventObject();
event.eventType = eventName;
el.fireEvent('on' + eventName, event);
} else {
// fall back to jQuery.trigger
this.trigger(eventName);
}
};
// </editor-fold>
function stringSearch (li, searchString, method, normalize) {
var stringTypes = [
'display',
'subtext',
'tokens'
],
searchSuccess = false;
for (var i = 0; i < stringTypes.length; i++) {
var stringType = stringTypes[i],
string = li[stringType];
if (string) {
string = string.toString();
// Strip HTML tags. This isn't perfect, but it's much faster than any other method
if (stringType === 'display') {
string = string.replace(/<[^>]+>/g, '');
}
if (normalize) string = normalizeToBase(string);
string = string.toUpperCase();
if (method === 'contains') {
searchSuccess = string.indexOf(searchString) >= 0;
} else {
searchSuccess = string.startsWith(searchString);
}
if (searchSuccess) break;
}
}
return searchSuccess;
}
function toInteger (value) {
return parseInt(value, 10) || 0;
}
// Borrowed from Lodash (_.deburr)
/** Used to map Latin Unicode letters to basic Latin letters. */
var deburredLetters = {
// Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'N', '\xf1': 'n',
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'Ae', '\xe6': 'ae',
'\xde': 'Th', '\xfe': 'th',
'\xdf': 'ss',
// Latin Extended-A block.
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
'\u0134': 'J', '\u0135': 'j',
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
'\u0163': 't', '\u0165': 't', '\u0167': 't',
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
'\u0174': 'W', '\u0175': 'w',
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
'\u0132': 'IJ', '\u0133': 'ij',
'\u0152': 'Oe', '\u0153': 'oe',
'\u0149': "'n", '\u017f': 's'
};
/** Used to match Latin Unicode letters (excluding mathematical operators). */
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** Used to compose unicode character classes. */
var rsComboMarksRange = '\\u0300-\\u036f',
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
rsComboSymbolsRange = '\\u20d0-\\u20ff',
rsComboMarksExtendedRange = '\\u1ab0-\\u1aff',
rsComboMarksSupplementRange = '\\u1dc0-\\u1dff',
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
/** Used to compose unicode capture groups. */
var rsCombo = '[' + rsComboRange + ']';
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo, 'g');
function deburrLetter (key) {
return deburredLetters[key];
};
function normalizeToBase (string) {
string = string.toString();
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
}
// List of HTML entities for escaping.
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};
// Functions for escaping and unescaping strings to/from HTML interpolation.
var createEscaper = function (map) {
var escaper = function (match) {
return map[match];
};
// Regexes for identifying a key that needs to be escaped.
var source = '(?:' + Object.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');
return function (string) {
string = string == null ? '' : '' + string;
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
};
};
var htmlEscape = createEscaper(escapeMap);
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var keyCodeMap = {
32: ' ',
48: '0',
49: '1',
50: '2',
51: '3',
52: '4',
53: '5',
54: '6',
55: '7',
56: '8',
57: '9',
59: ';',
65: 'A',
66: 'B',
67: 'C',
68: 'D',
69: 'E',
70: 'F',
71: 'G',
72: 'H',
73: 'I',
74: 'J',
75: 'K',
76: 'L',
77: 'M',
78: 'N',
79: 'O',
80: 'P',
81: 'Q',
82: 'R',
83: 'S',
84: 'T',
85: 'U',
86: 'V',
87: 'W',
88: 'X',
89: 'Y',
90: 'Z',
96: '0',
97: '1',
98: '2',
99: '3',
100: '4',
101: '5',
102: '6',
103: '7',
104: '8',
105: '9'
};
var keyCodes = {
ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key
ENTER: 13, // KeyboardEvent.which value for Enter key
SPACE: 32, // KeyboardEvent.which value for space key
TAB: 9, // KeyboardEvent.which value for tab key
ARROW_UP: 38, // KeyboardEvent.which value for up arrow key
ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key
}
var version = {
success: false,
major: '3'
};
try {
version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
version.major = version.full[0];
version.success = true;
} catch (err) {
// do nothing
}
var selectId = 0;
var EVENT_KEY = '.bs.select';
var classNames = {
DISABLED: 'disabled',
DIVIDER: 'divider',
SHOW: 'open',
DROPUP: 'dropup',
MENU: 'dropdown-menu',
MENURIGHT: 'dropdown-menu-right',
MENULEFT: 'dropdown-menu-left',
// to-do: replace with more advanced template/customization options
BUTTONCLASS: 'btn-default',
POPOVERHEADER: 'popover-title',
ICONBASE: 'glyphicon',
TICKICON: 'glyphicon-ok'
}
var Selector = {
MENU: '.' + classNames.MENU
}
var elementTemplates = {
span: document.createElement('span'),
i: document.createElement('i'),
subtext: document.createElement('small'),
a: document.createElement('a'),
li: document.createElement('li'),
whitespace: document.createTextNode('\u00A0'),
fragment: document.createDocumentFragment()
}
elementTemplates.a.setAttribute('role', 'option');
elementTemplates.subtext.className = 'text-muted';
elementTemplates.text = elementTemplates.span.cloneNode(false);
elementTemplates.text.className = 'text';
elementTemplates.checkMark = elementTemplates.span.cloneNode(false);
var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN);
var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE);
var generateOption = {
li: function (content, classes, optgroup) {
var li = elementTemplates.li.cloneNode(false);
if (content) {
if (content.nodeType === 1 || content.nodeType === 11) {
li.appendChild(content);
} else {
li.innerHTML = content;
}
}
if (typeof classes !== 'undefined' && classes !== '') li.className = classes;
if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup);
return li;
},
a: function (text, classes, inline) {
var a = elementTemplates.a.cloneNode(true);
if (text) {
if (text.nodeType === 11) {
a.appendChild(text);
} else {
a.insertAdjacentHTML('beforeend', text);
}
}
if (typeof classes !== 'undefined' && classes !== '') a.className = classes;
if (version.major === '4') a.classList.add('dropdown-item');
if (inline) a.setAttribute('style', inline);
return a;
},
text: function (options, useFragment) {
var textElement = elementTemplates.text.cloneNode(false),
subtextElement,
iconElement;
if (options.content) {
textElement.innerHTML = options.content;
} else {
textElement.textContent = options.text;
if (options.icon) {
var whitespace = elementTemplates.whitespace.cloneNode(false);
// need to use <i> for icons in the button to prevent a breaking change
// note: switch to span in next major release
iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false);
iconElement.className = options.iconBase + ' ' + options.icon;
elementTemplates.fragment.appendChild(iconElement);
elementTemplates.fragment.appendChild(whitespace);
}
if (options.subtext) {
subtextElement = elementTemplates.subtext.cloneNode(false);
subtextElement.textContent = options.subtext;
textElement.appendChild(subtextElement);
}
}
if (useFragment === true) {
while (textElement.childNodes.length > 0) {
elementTemplates.fragment.appendChild(textElement.childNodes[0]);
}
} else {
elementTemplates.fragment.appendChild(textElement);
}
return elementTemplates.fragment;
},
label: function (options) {
var textElement = elementTemplates.text.cloneNode(false),
subtextElement,
iconElement;
textElement.innerHTML = options.label;
if (options.icon) {
var whitespace = elementTemplates.whitespace.cloneNode(false);
iconElement = elementTemplates.span.cloneNode(false);
iconElement.className = options.iconBase + ' ' + options.icon;
elementTemplates.fragment.appendChild(iconElement);
elementTemplates.fragment.appendChild(whitespace);
}
if (options.subtext) {
subtextElement = elementTemplates.subtext.cloneNode(false);
subtextElement.textContent = options.subtext;
textElement.appendChild(subtextElement);
}
elementTemplates.fragment.appendChild(textElement);
return elementTemplates.fragment;
}
}
var Selectpicker = function (element, options) {
var that = this;
// bootstrap-select has been initialized - revert valHooks.select.set back to its original function
if (!valHooks.useDefault) {
$.valHooks.select.set = valHooks._set;
valHooks.useDefault = true;
}
this.$element = $(element);
this.$newElement = null;
this.$button = null;
this.$menu = null;
this.options = options;
this.selectpicker = {
main: {},
search: {},
current: {}, // current changes if a search is in progress
view: {},
keydown: {
keyHistory: '',
resetKeyHistory: {
start: function () {
return setTimeout(function () {
that.selectpicker.keydown.keyHistory = '';
}, 800);
}
}
}
};
// If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a
// data-attribute)
if (this.options.title === null) {
this.options.title = this.$element.attr('title');
}
// Format window padding
var winPad = this.options.windowPadding;
if (typeof winPad === 'number') {
this.options.windowPadding = [winPad, winPad, winPad, winPad];
}
// Expose public methods
this.val = Selectpicker.prototype.val;
this.render = Selectpicker.prototype.render;
this.refresh = Selectpicker.prototype.refresh;
this.setStyle = Selectpicker.prototype.setStyle;
this.selectAll = Selectpicker.prototype.selectAll;
this.deselectAll = Selectpicker.prototype.deselectAll;
this.destroy = Selectpicker.prototype.destroy;
this.remove = Selectpicker.prototype.remove;
this.show = Selectpicker.prototype.show;
this.hide = Selectpicker.prototype.hide;
this.init();
};
Selectpicker.VERSION = '1.13.12';
// part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
Selectpicker.DEFAULTS = {
noneSelectedText: 'Nothing selected',
noneResultsText: 'No results matched {0}',
countSelectedText: function (numSelected, numTotal) {
return (numSelected == 1) ? '{0} item selected' : '{0} items selected';
},
maxOptionsText: function (numAll, numGroup) {
return [
(numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',
(numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'
];
},
selectAllText: 'Select All',
deselectAllText: 'Deselect All',
doneButton: false,
doneButtonText: 'Close',
multipleSeparator: ', ',
styleBase: 'btn',
style: classNames.BUTTONCLASS,
size: 'auto',
title: null,
selectedTextFormat: 'values',
width: false,
container: false,
hideDisabled: false,
showSubtext: false,
showIcon: true,
showContent: true,
dropupAuto: true,
header: false,
liveSearch: false,
liveSearchPlaceholder: null,
liveSearchNormalize: false,
liveSearchStyle: 'contains',
actionsBox: false,
iconBase: classNames.ICONBASE,
tickIcon: classNames.TICKICON,
showTick: false,
template: {
caret: '<span class="caret"></span>'
},
maxOptions: false,
mobile: false,
selectOnTab: false,
dropdownAlignRight: false,
windowPadding: 0,
virtualScroll: 600,
display: false,
sanitize: true,
sanitizeFn: null,
whiteList: DefaultWhitelist
};
Selectpicker.prototype = {
constructor: Selectpicker,
init: function () {
var that = this,
id = this.$element.attr('id');
selectId++;
this.selectId = 'bs-select-' + selectId;
this.$element[0].classList.add('bs-select-hidden');
this.multiple = this.$element.prop('multiple');
this.autofocus = this.$element.prop('autofocus');
if (this.$element[0].classList.contains('show-tick')) {
this.options.showTick = true;
}
this.$newElement = this.createDropdown();
this.$element
.after(this.$newElement)
.prependTo(this.$newElement);
this.$button = this.$newElement.children('button');
this.$menu = this.$newElement.children(Selector.MENU);
this.$menuInner = this.$menu.children('.inner');
this.$searchbox = this.$menu.find('input');
this.$element[0].classList.remove('bs-select-hidden');
if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT);
if (typeof id !== 'undefined') {
this.$button.attr('data-id', id);
}
this.checkDisabled();
this.clickListener();
if (this.options.liveSearch) {
this.liveSearchListener();
this.focusedParent = this.$searchbox[0];
} else {
this.focusedParent = this.$menuInner[0];
}
this.setStyle();
this.render();
this.setWidth();
if (this.options.container) {
this.selectPosition();
} else {
this.$element.on('hide' + EVENT_KEY, function () {
if (that.isVirtual()) {
// empty menu on close
var menuInner = that.$menuInner[0],
emptyMenu = menuInner.firstChild.cloneNode(false);
// replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = ''
menuInner.replaceChild(emptyMenu, menuInner.firstChild);
menuInner.scrollTop = 0;
}
});
}
this.$menu.data('this', this);
this.$newElement.data('this', this);
if (this.options.mobile) this.mobile();
this.$newElement.on({
'hide.bs.dropdown': function (e) {
that.$element.trigger('hide' + EVENT_KEY, e);
},
'hidden.bs.dropdown': function (e) {
that.$element.trigger('hidden' + EVENT_KEY, e);
},
'show.bs.dropdown': function (e) {
that.$element.trigger('show' + EVENT_KEY, e);
},
'shown.bs.dropdown': function (e) {
that.$element.trigger('shown' + EVENT_KEY, e);
}
});
if (that.$element[0].hasAttribute('required')) {
this.$element.on('invalid' + EVENT_KEY, function () {
that.$button[0].classList.add('bs-invalid');
that.$element
.on('shown' + EVENT_KEY + '.invalid', function () {
that.$element
.val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened
.off('shown' + EVENT_KEY + '.invalid');
})
.on('rendered' + EVENT_KEY, function () {
// if select is no longer invalid, remove the bs-invalid class
if (this.validity.valid) that.$button[0].classList.remove('bs-invalid');
that.$element.off('rendered' + EVENT_KEY);
});
that.$button.on('blur' + EVENT_KEY, function () {
that.$element.trigger('focus').trigger('blur');
that.$button.off('blur' + EVENT_KEY);
});
});
}
setTimeout(function () {
that.createLi();
that.$element.trigger('loaded' + EVENT_KEY);
});
},
createDropdown: function () {
// Options
// If we are multiple or showTick option is set, then add the show-tick class
var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '',
multiselectable = this.multiple ? ' aria-multiselectable="true"' : '',
inputGroup = '',
autofocus = this.autofocus ? ' autofocus' : '';
if (version.major < 4 && this.$element.parent().hasClass('input-group')) {
inputGroup = ' input-group-btn';
}
// Elements
var drop,
header = '',
searchbox = '',
actionsbox = '',
donebutton = '';
if (this.options.header) {
header =
'<div class="' + classNames.POPOVERHEADER + '">' +
'<button type="button" class="close" aria-hidden="true">&times;</button>' +
this.options.header +
'</div>';
}
if (this.options.liveSearch) {
searchbox =
'<div class="bs-searchbox">' +
'<input type="search" class="form-control" autocomplete="off"' +
(
this.options.liveSearchPlaceholder === null ? ''
:
' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"'
) +
' role="combobox" aria-label="Search" aria-controls="' + this.selectId + '" aria-autocomplete="list">' +
'</div>';
}
if (this.multiple && this.options.actionsBox) {
actionsbox =
'<div class="bs-actionsbox">' +
'<div class="btn-group btn-group-sm btn-block">' +
'<button type="button" class="actions-btn bs-select-all btn ' + classNames.BUTTONCLASS + '">' +
this.options.selectAllText +
'</button>' +
'<button type="button" class="actions-btn bs-deselect-all btn ' + classNames.BUTTONCLASS + '">' +
this.options.deselectAllText +
'</button>' +
'</div>' +
'</div>';
}
if (this.multiple && this.options.doneButton) {
donebutton =
'<div class="bs-donebutton">' +
'<div class="btn-group btn-block">' +
'<button type="button" class="btn btn-sm ' + classNames.BUTTONCLASS + '">' +
this.options.doneButtonText +
'</button>' +
'</div>' +
'</div>';
}
drop =
'<div class="dropdown bootstrap-select' + showTick + inputGroup + '">' +
'<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" ' + (this.options.display === 'static' ? 'data-display="static"' : '') + 'data-toggle="dropdown"' + autofocus + ' role="combobox" aria-owns="' + this.selectId + '" aria-haspopup="listbox" aria-expanded="false">' +
'<div class="filter-option">' +
'<div class="filter-option-inner">' +
'<div class="filter-option-inner-inner"></div>' +
'</div> ' +
'</div>' +
(
version.major === '4' ? ''
:
'<span class="bs-caret">' +
this.options.template.caret +
'</span>'
) +
'</button>' +
'<div class="' + classNames.MENU + ' ' + (version.major === '4' ? '' : classNames.SHOW) + '">' +
header +
searchbox +
actionsbox +
'<div class="inner ' + classNames.SHOW + '" role="listbox" id="' + this.selectId + '" tabindex="-1" ' + multiselectable + '>' +
'<ul class="' + classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '') + '" role="presentation">' +
'</ul>' +
'</div>' +
donebutton +
'</div>' +
'</div>';
return $(drop);
},
setPositionData: function () {
this.selectpicker.view.canHighlight = [];
this.selectpicker.view.size = 0;
for (var i = 0; i < this.selectpicker.current.data.length; i++) {
var li = this.selectpicker.current.data[i],
canHighlight = true;
if (li.type === 'divider') {
canHighlight = false;
li.height = this.sizeInfo.dividerHeight;
} else if (li.type === 'optgroup-label') {
canHighlight = false;
li.height = this.sizeInfo.dropdownHeaderHeight;
} else {
li.height = this.sizeInfo.liHeight;
}
if (li.disabled) canHighlight = false;
this.selectpicker.view.canHighlight.push(canHighlight);
if (canHighlight) {
this.selectpicker.view.size++;
li.posinset = this.selectpicker.view.size;
}
li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height;
}
},
isVirtual: function () {
return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true;
},
createView: function (isSearching, setSize, refresh) {
var that = this,
scrollTop = 0,
active = [],
selected,
prevActive;
this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main;
this.setPositionData();
if (setSize) {
if (refresh) {
scrollTop = this.$menuInner[0].scrollTop;
} else if (!that.multiple) {
var element = that.$element[0],
selectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
if (typeof selectedIndex === 'number' && that.options.size !== false) {
var selectedData = that.selectpicker.main.data[selectedIndex],
position = selectedData && selectedData.position;
if (position) {
scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2);
}
}
}
}
scroll(scrollTop, true);
this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) {
if (!that.noScroll) scroll(this.scrollTop, updateValue);
that.noScroll = false;
});
function scroll (scrollTop, init) {
var size = that.selectpicker.current.elements.length,
chunks = [],
chunkSize,
chunkCount,
firstChunk,
lastChunk,
currentChunk,
prevPositions,
positionIsDifferent,
previousElements,
menuIsDifferent = true,
isVirtual = that.isVirtual();
that.selectpicker.view.scrollTop = scrollTop;
chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk
chunkCount = Math.round(size / chunkSize) || 1; // number of chunks
for (var i = 0; i < chunkCount; i++) {
var endOfChunk = (i + 1) * chunkSize;
if (i === chunkCount - 1) {
endOfChunk = size;
}
chunks[i] = [
(i) * chunkSize + (!i ? 0 : 1),
endOfChunk
];
if (!size) break;
if (currentChunk === undefined && scrollTop - 1 <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) {
currentChunk = i;
}
}
if (currentChunk === undefined) currentChunk = 0;
prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1];
// always display previous, current, and next chunks
firstChunk = Math.max(0, currentChunk - 1);
lastChunk = Math.min(chunkCount - 1, currentChunk + 1);
that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0);
that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0);
positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1;
if (that.activeIndex !== undefined) {
prevActive = that.selectpicker.main.elements[that.prevActiveIndex];
active = that.selectpicker.main.elements[that.activeIndex];
selected = that.selectpicker.main.elements[that.selectedIndex];
if (init) {
if (that.activeIndex !== that.selectedIndex) {
that.defocusItem(active);
}
that.activeIndex = undefined;
}
if (that.activeIndex && that.activeIndex !== that.selectedIndex) {
that.defocusItem(selected);
}
}
if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) {
that.defocusItem(prevActive);
}
if (init || positionIsDifferent) {
previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : [];
if (isVirtual === false) {
that.selectpicker.view.visibleElements = that.selectpicker.current.elements;
} else {
that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1);
}
that.setOptionStatus();
// if searching, check to make sure the list has actually been updated before updating DOM
// this prevents unnecessary repaints
if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements);
// if virtual scroll is disabled and not searching,
// menu should never need to be updated more than once
if ((init || isVirtual === true) && menuIsDifferent) {
var menuInner = that.$menuInner[0],
menuFragment = document.createDocumentFragment(),
emptyMenu = menuInner.firstChild.cloneNode(false),
marginTop,
marginBottom,
elements = that.selectpicker.view.visibleElements,
toSanitize = [];
// replace the existing UL with an empty one - this is faster than $.empty()
menuInner.replaceChild(emptyMenu, menuInner.firstChild);
for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) {
var element = elements[i],
elText,
elementData;
if (that.options.sanitize) {
elText = element.lastChild;
if (elText) {
elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0];
if (elementData && elementData.content && !elementData.sanitized) {
toSanitize.push(elText);
elementData.sanitized = true;
}
}
}
menuFragment.appendChild(element);
}
if (that.options.sanitize && toSanitize.length) {
sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn);
}
if (isVirtual === true) {
marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position);
marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position);
menuInner.firstChild.style.marginTop = marginTop + 'px';
menuInner.firstChild.style.marginBottom = marginBottom + 'px';
} else {
menuInner.firstChild.style.marginTop = 0;
menuInner.firstChild.style.marginBottom = 0;
}
menuInner.firstChild.appendChild(menuFragment);
// if an option is encountered that is wider than the current menu width, update the menu width accordingly
// switch to ResizeObserver with increased browser support
if (isVirtual === true && that.sizeInfo.hasScrollBar) {
var menuInnerInnerWidth = menuInner.firstChild.offsetWidth;
if (init && menuInnerInnerWidth < that.sizeInfo.menuInnerInnerWidth && that.sizeInfo.totalMenuWidth > that.sizeInfo.selectWidth) {
menuInner.firstChild.style.minWidth = that.sizeInfo.menuInnerInnerWidth + 'px';
} else if (menuInnerInnerWidth > that.sizeInfo.menuInnerInnerWidth) {
// set to 0 to get actual width of menu
that.$menu[0].style.minWidth = 0;
var actualMenuWidth = menuInner.firstChild.offsetWidth;
if (actualMenuWidth > that.sizeInfo.menuInnerInnerWidth) {
that.sizeInfo.menuInnerInnerWidth = actualMenuWidth;
menuInner.firstChild.style.minWidth = that.sizeInfo.menuInnerInnerWidth + 'px';
}
// reset to default CSS styling
that.$menu[0].style.minWidth = '';
}
}
}
}
that.prevActiveIndex = that.activeIndex;
if (!that.options.liveSearch) {
that.$menuInner.trigger('focus');
} else if (isSearching && init) {
var index = 0,
newActive;
if (!that.selectpicker.view.canHighlight[index]) {
index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true);
}
newActive = that.selectpicker.view.visibleElements[index];
that.defocusItem(that.selectpicker.view.currentActive);
that.activeIndex = (that.selectpicker.current.data[index] || {}).index;
that.focusItem(newActive);
}
}
$(window)
.off('resize' + EVENT_KEY + '.' + this.selectId + '.createView')
.on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () {
var isActive = that.$newElement.hasClass(classNames.SHOW);
if (isActive) scroll(that.$menuInner[0].scrollTop);
});
},
focusItem: function (li, liData, noStyle) {
if (li) {
liData = liData || this.selectpicker.main.data[this.activeIndex];
var a = li.firstChild;
if (a) {
a.setAttribute('aria-setsize', this.selectpicker.view.size);
a.setAttribute('aria-posinset', liData.posinset);
if (noStyle !== true) {
this.focusedParent.setAttribute('aria-activedescendant', a.id);
li.classList.add('active');
a.classList.add('active');
}
}
}
},
defocusItem: function (li) {
if (li) {
li.classList.remove('active');
if (li.firstChild) li.firstChild.classList.remove('active');
}
},
setPlaceholder: function () {
var updateIndex = false;
if (this.options.title && !this.multiple) {
if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option');
// this option doesn't create a new <li> element, but does add a new option at the start,
// so startIndex should increase to prevent having to check every option for the bs-title-option class
updateIndex = true;
var element = this.$element[0],
isSelected = false,
titleNotAppended = !this.selectpicker.view.titleOption.parentNode;
if (titleNotAppended) {
// Use native JS to prepend option (faster)
this.selectpicker.view.titleOption.className = 'bs-title-option';
this.selectpicker.view.titleOption.value = '';
// Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option.
// the selected item may have been changed by user or programmatically before the bootstrap select plugin runs,
// if so, the select will have the data-selected attribute
var $opt = $(element.options[element.selectedIndex]);
isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined;
}
if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) {
element.insertBefore(this.selectpicker.view.titleOption, element.firstChild);
}
// Set selected *after* appending to select,
// otherwise the option doesn't get selected in IE
// set using selectedIndex, as setting the selected attr to true here doesn't work in IE11
if (isSelected) element.selectedIndex = 0;
}
return updateIndex;
},
createLi: function () {
var that = this,
iconBase = this.options.iconBase,
optionSelector = ':not([hidden]):not([data-hidden="true"])',
mainElements = [],
mainData = [],
widestOptionLength = 0,
optID = 0,
startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop
if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) {
elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark';
elementTemplates.a.appendChild(elementTemplates.checkMark);
}
var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector);
function addDivider (config) {
var previousData = mainData[mainData.length - 1];
// ensure optgroup doesn't create back-to-back dividers
if (
previousData &&
previousData.type === 'divider' &&
(previousData.optID || config.optID)
) {
return;
}
config = config || {};
config.type = 'divider';
mainElements.push(
generateOption.li(
false,
classNames.DIVIDER,
(config.optID ? config.optID + 'div' : undefined)
)
);
mainData.push(config);
}
function addOption (option, config) {
config = config || {};
config.divider = option.getAttribute('data-divider') === 'true';
if (config.divider) {
addDivider({
optID: config.optID
});
} else {
var liIndex = mainData.length,
cssText = option.style.cssText,
inlineStyle = cssText ? htmlEscape(cssText) : '',
optionClass = (option.className || '') + (config.optgroupClass || '');
if (config.optID) optionClass = 'opt ' + optionClass;
config.text = option.textContent;
config.content = option.getAttribute('data-content');
config.tokens = option.getAttribute('data-tokens');
config.subtext = option.getAttribute('data-subtext');
config.icon = option.getAttribute('data-icon');
config.iconBase = iconBase;
var textElement = generateOption.text(config);
var liElement = generateOption.li(
generateOption.a(
textElement,
optionClass,
inlineStyle
),
'',
config.optID
);
if (liElement.firstChild) {
liElement.firstChild.id = that.selectId + '-' + liIndex;
}
mainElements.push(liElement);
option.liIndex = liIndex;
config.display = config.content || config.text;
config.type = 'option';
config.index = liIndex;
config.option = option;
config.disabled = config.disabled || option.disabled;
mainData.push(config);
var combinedLength = 0;
// count the number of characters in the option - not perfect, but should work in most cases
if (config.display) combinedLength += config.display.length;
if (config.subtext) combinedLength += config.subtext.length;
// if there is an icon, ensure this option's width is checked
if (config.icon) combinedLength += 1;
if (combinedLength > widestOptionLength) {
widestOptionLength = combinedLength;
// guess which option is the widest
// use this when calculating menu width
// not perfect, but it's fast, and the width will be updating accordingly when scrolling
that.selectpicker.view.widestOption = mainElements[mainElements.length - 1];
}
}
}
function addOptgroup (index, selectOptions) {
var optgroup = selectOptions[index],
previous = selectOptions[index - 1],
next = selectOptions[index + 1],
options = optgroup.querySelectorAll('option' + optionSelector);
if (!options.length) return;
var config = {
label: htmlEscape(optgroup.label),
subtext: optgroup.getAttribute('data-subtext'),
icon: optgroup.getAttribute('data-icon'),
iconBase: iconBase
},
optgroupClass = ' ' + (optgroup.className || ''),
headerIndex,
lastIndex;
optID++;
if (previous) {
addDivider({ optID: optID });
}
var labelElement = generateOption.label(config);
mainElements.push(
generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID)
);
mainData.push({
display: config.label,
subtext: config.subtext,
type: 'optgroup-label',
optID: optID
});
for (var j = 0, len = options.length; j < len; j++) {
var option = options[j];
if (j === 0) {
headerIndex = mainData.length - 1;
lastIndex = headerIndex + len;
}
addOption(option, {
headerIndex: headerIndex,
lastIndex: lastIndex,
optID: optID,
optgroupClass: optgroupClass,
disabled: optgroup.disabled
});
}
if (next) {
addDivider({ optID: optID });
}
}
for (var len = selectOptions.length; startIndex < len; startIndex++) {
var item = selectOptions[startIndex];
if (item.tagName !== 'OPTGROUP') {
addOption(item, {});
} else {
addOptgroup(startIndex, selectOptions);
}
}
this.selectpicker.main.elements = mainElements;
this.selectpicker.main.data = mainData;
this.selectpicker.current = this.selectpicker.main;
},
findLis: function () {
return this.$menuInner.find('.inner > li');
},
render: function () {
// ensure titleOption is appended and selected (if necessary) before getting selectedOptions
this.setPlaceholder();
var that = this,
element = this.$element[0],
selectedOptions = getSelectedOptions(element, this.options.hideDisabled),
selectedCount = selectedOptions.length,
button = this.$button[0],
buttonInner = button.querySelector('.filter-option-inner-inner'),
multipleSeparator = document.createTextNode(this.options.multipleSeparator),
titleFragment = elementTemplates.fragment.cloneNode(false),
showCount,
countMax,
hasContent = false;
button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions));
this.tabIndex();
if (this.options.selectedTextFormat === 'static') {
titleFragment = generateOption.text({ text: this.options.title }, true);
} else {
showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1;
// determine if the number of selected options will be shown (showCount === true)
if (showCount) {
countMax = this.options.selectedTextFormat.split('>');
showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2);
}
// only loop through all selected options if the count won't be shown
if (showCount === false) {
for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) {
if (selectedIndex < 50) {
var option = selectedOptions[selectedIndex],
titleOptions = {},
thisData = {
content: option.getAttribute('data-content'),
subtext: option.getAttribute('data-subtext'),
icon: option.getAttribute('data-icon')
};
if (this.multiple && selectedIndex > 0) {
titleFragment.appendChild(multipleSeparator.cloneNode(false));
}
if (option.title) {
titleOptions.text = option.title;
} else if (thisData.content && that.options.showContent) {
titleOptions.content = thisData.content.toString();
hasContent = true;
} else {
if (that.options.showIcon) {
titleOptions.icon = thisData.icon;
titleOptions.iconBase = this.options.iconBase;
}
if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext;
titleOptions.text = option.textContent.trim();
}
titleFragment.appendChild(generateOption.text(titleOptions, true));
} else {
break;
}
}
// add ellipsis
if (selectedCount > 49) {
titleFragment.appendChild(document.createTextNode('...'));
}
} else {
var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';
if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
// If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc.
var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length,
tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText;
titleFragment = generateOption.text({
text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString())
}, true);
}
}
if (this.options.title == undefined) {
// use .attr to ensure undefined is returned if title attribute is not set
this.options.title = this.$element.attr('title');
}
// If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText
if (!titleFragment.childNodes.length) {
titleFragment = generateOption.text({
text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText
}, true);
}
// strip all HTML tags and trim the result, then unescape any escaped tags
button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim();
if (this.options.sanitize && hasContent) {
sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn);
}
buttonInner.innerHTML = '';
buttonInner.appendChild(titleFragment);
if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) {
var filterExpand = button.querySelector('.filter-expand'),
clone = buttonInner.cloneNode(true);
clone.className = 'filter-expand';
if (filterExpand) {
button.replaceChild(clone, filterExpand);
} else {
button.appendChild(clone);
}
}
this.$element.trigger('rendered' + EVENT_KEY);
},
/**
* @param [style]
* @param [status]
*/
setStyle: function (newStyle, status) {
var button = this.$button[0],
newElement = this.$newElement[0],
style = this.options.style.trim(),
buttonClass;
if (this.$element.attr('class')) {
this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ''));
}
if (version.major < 4) {
newElement.classList.add('bs3');
if (newElement.parentNode.classList.contains('input-group') &&
(newElement.previousElementSibling || newElement.nextElementSibling) &&
(newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon')
) {
newElement.classList.add('bs3-has-addon');
}
}
if (newStyle) {
buttonClass = newStyle.trim();
} else {
buttonClass = style;
}
if (status == 'add') {
if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
} else if (status == 'remove') {
if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' '));
} else {
if (style) button.classList.remove.apply(button.classList, style.split(' '));
if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
}
},
liHeight: function (refresh) {
if (!refresh && (this.options.size === false || this.sizeInfo)) return;
if (!this.sizeInfo) this.sizeInfo = {};
var newElement = document.createElement('div'),
menu = document.createElement('div'),
menuInner = document.createElement('div'),
menuInnerInner = document.createElement('ul'),
divider = document.createElement('li'),
dropdownHeader = document.createElement('li'),
li = document.createElement('li'),
a = document.createElement('a'),
text = document.createElement('span'),
header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null,
search = this.options.liveSearch ? document.createElement('div') : null,
actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null,
doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null,
firstOption = this.$element.find('option')[0];
this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth;
text.className = 'text';
a.className = 'dropdown-item ' + (firstOption ? firstOption.className : '');
newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW;
newElement.style.width = 0; // ensure button width doesn't affect natural width of menu when calculating
if (this.options.width === 'auto') menu.style.minWidth = 0;
menu.className = classNames.MENU + ' ' + classNames.SHOW;
menuInner.className = 'inner ' + classNames.SHOW;
menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '');
divider.className = classNames.DIVIDER;
dropdownHeader.className = 'dropdown-header';
text.appendChild(document.createTextNode('\u200b'));
a.appendChild(text);
li.appendChild(a);
dropdownHeader.appendChild(text.cloneNode(true));
if (this.selectpicker.view.widestOption) {
menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true));
}
menuInnerInner.appendChild(li);
menuInnerInner.appendChild(divider);
menuInnerInner.appendChild(dropdownHeader);
if (header) menu.appendChild(header);
if (search) {
var input = document.createElement('input');
search.className = 'bs-searchbox';
input.className = 'form-control';
search.appendChild(input);
menu.appendChild(search);
}
if (actions) menu.appendChild(actions);
menuInner.appendChild(menuInnerInner);
menu.appendChild(menuInner);
if (doneButton) menu.appendChild(doneButton);
newElement.appendChild(menu);
document.body.appendChild(newElement);
var liHeight = li.offsetHeight,
dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0,
headerHeight = header ? header.offsetHeight : 0,
searchHeight = search ? search.offsetHeight : 0,
actionsHeight = actions ? actions.offsetHeight : 0,
doneButtonHeight = doneButton ? doneButton.offsetHeight : 0,
dividerHeight = $(divider).outerHeight(true),
// fall back to jQuery if getComputedStyle is not supported
menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false,
menuWidth = menu.offsetWidth,
$menu = menuStyle ? null : $(menu),
menuPadding = {
vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) +
toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) +
toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) +
toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')),
horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) +
toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) +
toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) +
toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth'))
},
menuExtras = {
vert: menuPadding.vert +
toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) +
toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2,
horiz: menuPadding.horiz +
toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) +
toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2
},
scrollBarWidth;
menuInner.style.overflowY = 'scroll';
scrollBarWidth = menu.offsetWidth - menuWidth;
document.body.removeChild(newElement);
this.sizeInfo.liHeight = liHeight;
this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight;
this.sizeInfo.headerHeight = headerHeight;
this.sizeInfo.searchHeight = searchHeight;
this.sizeInfo.actionsHeight = actionsHeight;
this.sizeInfo.doneButtonHeight = doneButtonHeight;
this.sizeInfo.dividerHeight = dividerHeight;
this.sizeInfo.menuPadding = menuPadding;
this.sizeInfo.menuExtras = menuExtras;
this.sizeInfo.menuWidth = menuWidth;
this.sizeInfo.menuInnerInnerWidth = menuWidth - menuPadding.horiz;
this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth;
this.sizeInfo.scrollBarWidth = scrollBarWidth;
this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight;
this.setPositionData();
},
getSelectPosition: function () {
var that = this,
$window = $(window),
pos = that.$newElement.offset(),
$container = $(that.options.container),
containerPos;
if (that.options.container && $container.length && !$container.is('body')) {
containerPos = $container.offset();
containerPos.top += parseInt($container.css('borderTopWidth'));
containerPos.left += parseInt($container.css('borderLeftWidth'));
} else {
containerPos = { top: 0, left: 0 };
}
var winPad = that.options.windowPadding;
this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop();
this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2];
this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft();
this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1];
this.sizeInfo.selectOffsetTop -= winPad[0];
this.sizeInfo.selectOffsetLeft -= winPad[3];
},
setMenuSize: function (isAuto) {
this.getSelectPosition();
var selectWidth = this.sizeInfo.selectWidth,
liHeight = this.sizeInfo.liHeight,
headerHeight = this.sizeInfo.headerHeight,
searchHeight = this.sizeInfo.searchHeight,
actionsHeight = this.sizeInfo.actionsHeight,
doneButtonHeight = this.sizeInfo.doneButtonHeight,
divHeight = this.sizeInfo.dividerHeight,
menuPadding = this.sizeInfo.menuPadding,
menuInnerHeight,
menuHeight,
divLength = 0,
minHeight,
_minHeight,
maxHeight,
menuInnerMinHeight,
estimate;
if (this.options.dropupAuto) {
// Get the estimated height of the menu without scrollbars.
// This is useful for smaller menus, where there might be plenty of room
// below the button without setting dropup, but we can't know
// the exact height of the menu until createView is called later
estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert;
this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot);
}
if (this.options.size === 'auto') {
_minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0;
menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert;
minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0);
if (this.$newElement.hasClass(classNames.DROPUP)) {
menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert;
}
maxHeight = menuHeight;
menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert;
} else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
for (var i = 0; i < this.options.size; i++) {
if (this.selectpicker.current.data[i].type === 'divider') divLength++;
}
menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert;
menuInnerHeight = menuHeight - menuPadding.vert;
maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
minHeight = menuInnerMinHeight = '';
}
this.$menu.css({
'max-height': maxHeight + 'px',
'overflow': 'hidden',
'min-height': minHeight + 'px'
});
this.$menuInner.css({
'max-height': menuInnerHeight + 'px',
'overflow-y': 'auto',
'min-height': menuInnerMinHeight + 'px'
});
// ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView
this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1);
if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) {
this.sizeInfo.hasScrollBar = true;
this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth;
}
if (this.options.dropdownAlignRight === 'auto') {
this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth));
}
if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update();
},
setSize: function (refresh) {
this.liHeight(refresh);
if (this.options.header) this.$menu.css('padding-top', 0);
if (this.options.size === false) return;
var that = this,
$window = $(window);
this.setMenuSize();
if (this.options.liveSearch) {
this.$searchbox
.off('input.setMenuSize propertychange.setMenuSize')
.on('input.setMenuSize propertychange.setMenuSize', function () {
return that.setMenuSize();
});
}
if (this.options.size === 'auto') {
$window
.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize')
.on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () {
return that.setMenuSize();
});
} else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
$window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize');
}
that.createView(false, true, refresh);
},
setWidth: function () {
var that = this;
if (this.options.width === 'auto') {
requestAnimationFrame(function () {
that.$menu.css('min-width', '0');
that.$element.on('loaded' + EVENT_KEY, function () {
that.liHeight();
that.setMenuSize();
// Get correct width if element is hidden
var $selectClone = that.$newElement.clone().appendTo('body'),
btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth();
$selectClone.remove();
// Set width to whatever's larger, button title or longest option
that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth);
that.$newElement.css('width', that.sizeInfo.selectWidth + 'px');
});
});
} else if (this.options.width === 'fit') {
// Remove inline min-width so width can be changed from 'auto'
this.$menu.css('min-width', '');
this.$newElement.css('width', '').addClass('fit-width');
} else if (this.options.width) {
// Remove inline min-width so width can be changed from 'auto'
this.$menu.css('min-width', '');
this.$newElement.css('width', this.options.width);
} else {
// Remove inline min-width/width so width can be changed
this.$menu.css('min-width', '');
this.$newElement.css('width', '');
}
// Remove fit-width class if width is changed programmatically
if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
this.$newElement[0].classList.remove('fit-width');
}
},
selectPosition: function () {
this.$bsContainer = $('<div class="bs-container" />');
var that = this,
$container = $(this.options.container),
pos,
containerPos,
actualHeight,
getPlacement = function ($element) {
var containerPosition = {},
// fall back to dropdown's default display setting if display is not manually set
display = that.options.display || (
// Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default
$.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display
: false
);
that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP));
pos = $element.offset();
if (!$container.is('body')) {
containerPos = $container.offset();
containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop();
containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft();
} else {
containerPos = { top: 0, left: 0 };
}
actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight;
// Bootstrap 4+ uses Popper for menu positioning
if (version.major < 4 || display === 'static') {
containerPosition.top = pos.top - containerPos.top + actualHeight;
containerPosition.left = pos.left - containerPos.left;
}
containerPosition.width = $element[0].offsetWidth;
that.$bsContainer.css(containerPosition);
};
this.$button.on('click.bs.dropdown.data-api', function () {
if (that.isDisabled()) {
return;
}
getPlacement(that.$newElement);
that.$bsContainer
.appendTo(that.options.container)
.toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW))
.append(that.$menu);
});
$(window)
.off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId)
.on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () {
var isActive = that.$newElement.hasClass(classNames.SHOW);
if (isActive) getPlacement(that.$newElement);
});
this.$element.on('hide' + EVENT_KEY, function () {
that.$menu.data('height', that.$menu.height());
that.$bsContainer.detach();
});
},
setOptionStatus: function (selectedOnly) {
var that = this;
that.noScroll = false;
if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) {
for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) {
var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0],
option = liData.option;
if (option) {
if (selectedOnly !== true) {
that.setDisabled(
liData.index,
liData.disabled
);
}
that.setSelected(
liData.index,
option.selected
);
}
}
}
},
/**
* @param {number} index - the index of the option that is being changed
* @param {boolean} selected - true if the option is being selected, false if being deselected
*/
setSelected: function (index, selected) {
var li = this.selectpicker.main.elements[index],
liData = this.selectpicker.main.data[index],
activeIndexIsSet = this.activeIndex !== undefined,
thisIsActive = this.activeIndex === index,
prevActive,
a,
// if current option is already active
// OR
// if the current option is being selected, it's NOT multiple, and
// activeIndex is undefined:
// - when the menu is first being opened, OR
// - after a search has been performed, OR
// - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex)
keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet);
liData.selected = selected;
a = li.firstChild;
if (selected) {
this.selectedIndex = index;
}
li.classList.toggle('selected', selected);
if (keepActive) {
this.focusItem(li, liData);
this.selectpicker.view.currentActive = li;
this.activeIndex = index;
} else {
this.defocusItem(li);
}
if (a) {
a.classList.toggle('selected', selected);
if (selected) {
a.setAttribute('aria-selected', true);
} else {
if (this.multiple) {
a.setAttribute('aria-selected', false);
} else {
a.removeAttribute('aria-selected');
}
}
}
if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) {
prevActive = this.selectpicker.main.elements[this.prevActiveIndex];
this.defocusItem(prevActive);
}
},
/**
* @param {number} index - the index of the option that is being disabled
* @param {boolean} disabled - true if the option is being disabled, false if being enabled
*/
setDisabled: function (index, disabled) {
var li = this.selectpicker.main.elements[index],
a;
this.selectpicker.main.data[index].disabled = disabled;
a = li.firstChild;
li.classList.toggle(classNames.DISABLED, disabled);
if (a) {
if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled);
if (disabled) {
a.setAttribute('aria-disabled', disabled);
a.setAttribute('tabindex', -1);
} else {
a.removeAttribute('aria-disabled');
a.setAttribute('tabindex', 0);
}
}
},
isDisabled: function () {
return this.$element[0].disabled;
},
checkDisabled: function () {
if (this.isDisabled()) {
this.$newElement[0].classList.add(classNames.DISABLED);
this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true);
} else {
if (this.$button[0].classList.contains(classNames.DISABLED)) {
this.$newElement[0].classList.remove(classNames.DISABLED);
this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false);
}
if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) {
this.$button.removeAttr('tabindex');
}
}
},
tabIndex: function () {
if (this.$element.data('tabindex') !== this.$element.attr('tabindex') &&
(this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) {
this.$element.data('tabindex', this.$element.attr('tabindex'));
this.$button.attr('tabindex', this.$element.data('tabindex'));
}
this.$element.attr('tabindex', -98);
},
clickListener: function () {
var that = this,
$document = $(document);
$document.data('spaceSelect', false);
this.$button.on('keyup', function (e) {
if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) {
e.preventDefault();
$document.data('spaceSelect', false);
}
});
this.$newElement.on('show.bs.dropdown', function () {
if (version.major > 3 && !that.dropdown) {
that.dropdown = that.$button.data('bs.dropdown');
that.dropdown._menu = that.$menu[0];
}
});
this.$button.on('click.bs.dropdown.data-api', function () {
if (!that.$newElement.hasClass(classNames.SHOW)) {
that.setSize();
}
});
function setFocus () {
if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
} else {
that.$menuInner.trigger('focus');
}
}
function checkPopperExists () {
if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) {
setFocus();
} else {
requestAnimationFrame(checkPopperExists);
}
}
this.$element.on('shown' + EVENT_KEY, function () {
if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) {
that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop;
}
if (version.major > 3) {
requestAnimationFrame(checkPopperExists);
} else {
setFocus();
}
});
// ensure posinset and setsize are correct before selecting an option via a click
this.$menuInner.on('mouseenter', 'li a', function (e) {
var hoverLi = this.parentElement,
position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi),
hoverData = that.selectpicker.current.data[index + position0];
that.focusItem(hoverLi, hoverData, true);
});
this.$menuInner.on('click', 'li a', function (e, retainActive) {
var $this = $(this),
element = that.$element[0],
position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
clickedData = that.selectpicker.current.data[$this.parent().index() + position0],
clickedIndex = clickedData.index,
prevValue = getSelectValues(element),
prevIndex = element.selectedIndex,
prevOption = element.options[prevIndex],
triggerChange = true;
// Don't close on multi choice menu
if (that.multiple && that.options.maxOptions !== 1) {
e.stopPropagation();
}
e.preventDefault();
// Don't run if the select is disabled
if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) {
var option = clickedData.option,
$option = $(option),
state = option.selected,
$optgroup = $option.parent('optgroup'),
$optgroupOptions = $optgroup.find('option'),
maxOptions = that.options.maxOptions,
maxOptionsGrp = $optgroup.data('maxOptions') || false;
if (clickedIndex === that.activeIndex) retainActive = true;
if (!retainActive) {
that.prevActiveIndex = that.activeIndex;
that.activeIndex = undefined;
}
if (!that.multiple) { // Deselect all others if not multi select box
if (prevOption) prevOption.selected = false;
option.selected = true;
that.setSelected(clickedIndex, true);
} else { // Toggle the one we have chosen if we are multi select.
option.selected = !state;
that.setSelected(clickedIndex, !state);
$this.trigger('blur');
if (maxOptions !== false || maxOptionsGrp !== false) {
var maxReached = maxOptions < getSelectedOptions(element).length,
maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length;
if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
if (maxOptions && maxOptions == 1) {
element.selectedIndex = -1;
option.selected = true;
that.setOptionStatus(true);
} else if (maxOptionsGrp && maxOptionsGrp == 1) {
for (var i = 0; i < $optgroupOptions.length; i++) {
var _option = $optgroupOptions[i];
_option.selected = false;
that.setSelected(_option.liIndex, false);
}
option.selected = true;
that.setSelected(clickedIndex, true);
} else {
var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText,
maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText,
maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
$notify = $('<div class="notify"></div>');
// If {var} is set in array, replace it
/** @deprecated */
if (maxOptionsArr[2]) {
maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
}
option.selected = false;
that.$menu.append($notify);
if (maxOptions && maxReached) {
$notify.append($('<div>' + maxTxt + '</div>'));
triggerChange = false;
that.$element.trigger('maxReached' + EVENT_KEY);
}
if (maxOptionsGrp && maxReachedGrp) {
$notify.append($('<div>' + maxTxtGrp + '</div>'));
triggerChange = false;
that.$element.trigger('maxReachedGrp' + EVENT_KEY);
}
setTimeout(function () {
that.setSelected(clickedIndex, false);
}, 10);
$notify[0].classList.add('fadeOut');
setTimeout(function () {
$notify.remove();
}, 1050);
}
}
}
}
if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) {
that.$button.trigger('focus');
} else if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
}
// Trigger select 'change'
if (triggerChange) {
if (that.multiple || prevIndex !== element.selectedIndex) {
// $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed.
changedArguments = [option.index, $option.prop('selected'), prevValue];
that.$element
.triggerNative('change');
}
}
}
});
this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) {
if (e.currentTarget == this) {
e.preventDefault();
e.stopPropagation();
if (that.options.liveSearch && !$(e.target).hasClass('close')) {
that.$searchbox.trigger('focus');
} else {
that.$button.trigger('focus');
}
}
});
this.$menuInner.on('click', '.divider, .dropdown-header', function (e) {
e.preventDefault();
e.stopPropagation();
if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
} else {
that.$button.trigger('focus');
}
});
this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () {
that.$button.trigger('click');
});
this.$searchbox.on('click', function (e) {
e.stopPropagation();
});
this.$menu.on('click', '.actions-btn', function (e) {
if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
} else {
that.$button.trigger('focus');
}
e.preventDefault();
e.stopPropagation();
if ($(this).hasClass('bs-select-all')) {
that.selectAll();
} else {
that.deselectAll();
}
});
this.$element
.on('change' + EVENT_KEY, function () {
that.render();
that.$element.trigger('changed' + EVENT_KEY, changedArguments);
changedArguments = null;
})
.on('focus' + EVENT_KEY, function () {
if (!that.options.mobile) that.$button.trigger('focus');
});
},
liveSearchListener: function () {
var that = this,
noResults = document.createElement('li');
this.$button.on('click.bs.dropdown.data-api', function () {
if (!!that.$searchbox.val()) {
that.$searchbox.val('');
}
});
this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) {
e.stopPropagation();
});
this.$searchbox.on('input propertychange', function () {
var searchValue = that.$searchbox.val();
that.selectpicker.search.elements = [];
that.selectpicker.search.data = [];
if (searchValue) {
var i,
searchMatch = [],
q = searchValue.toUpperCase(),
cache = {},
cacheArr = [],
searchStyle = that._searchStyle(),
normalizeSearch = that.options.liveSearchNormalize;
if (normalizeSearch) q = normalizeToBase(q);
that._$lisSelected = that.$menuInner.find('.selected');
for (var i = 0; i < that.selectpicker.main.data.length; i++) {
var li = that.selectpicker.main.data[i];
if (!cache[i]) {
cache[i] = stringSearch(li, q, searchStyle, normalizeSearch);
}
if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) {
if (li.headerIndex > 0) {
cache[li.headerIndex - 1] = true;
cacheArr.push(li.headerIndex - 1);
}
cache[li.headerIndex] = true;
cacheArr.push(li.headerIndex);
cache[li.lastIndex + 1] = true;
}
if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i);
}
for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) {
var index = cacheArr[i],
prevIndex = cacheArr[i - 1],
li = that.selectpicker.main.data[index],
liPrev = that.selectpicker.main.data[prevIndex];
if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) {
that.selectpicker.search.data.push(li);
searchMatch.push(that.selectpicker.main.elements[index]);
}
}
that.activeIndex = undefined;
that.noScroll = true;
that.$menuInner.scrollTop(0);
that.selectpicker.search.elements = searchMatch;
that.createView(true);
if (!searchMatch.length) {
noResults.className = 'no-results';
noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"');
that.$menuInner[0].firstChild.appendChild(noResults);
}
} else {
that.$menuInner.scrollTop(0);
that.createView(false);
}
});
},
_searchStyle: function () {
return this.options.liveSearchStyle || 'contains';
},
val: function (value) {
var element = this.$element[0];
if (typeof value !== 'undefined') {
var prevValue = getSelectValues(element);
changedArguments = [null, null, prevValue];
this.$element
.val(value)
.trigger('changed' + EVENT_KEY, changedArguments);
if (this.$newElement.hasClass(classNames.SHOW)) {
if (this.multiple) {
this.setOptionStatus(true);
} else {
var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
if (typeof liSelectedIndex === 'number') {
this.setSelected(this.selectedIndex, false);
this.setSelected(liSelectedIndex, true);
}
}
}
this.render();
changedArguments = null;
return this.$element;
} else {
return this.$element.val();
}
},
changeAll: function (status) {
if (!this.multiple) return;
if (typeof status === 'undefined') status = true;
var element = this.$element[0],
previousSelected = 0,
currentSelected = 0,
prevValue = getSelectValues(element);
element.classList.add('bs-select-hidden');
for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) {
var liData = this.selectpicker.current.data[i],
option = liData.option;
if (option && !liData.disabled && liData.type !== 'divider') {
if (liData.selected) previousSelected++;
option.selected = status;
if (status) currentSelected++;
}
}
element.classList.remove('bs-select-hidden');
if (previousSelected === currentSelected) return;
this.setOptionStatus();
changedArguments = [null, null, prevValue];
this.$element
.triggerNative('change');
},
selectAll: function () {
return this.changeAll(true);
},
deselectAll: function () {
return this.changeAll(false);
},
toggle: function (e) {
e = e || window.event;
if (e) e.stopPropagation();
this.$button.trigger('click.bs.dropdown.data-api');
},
keydown: function (e) {
var $this = $(this),
isToggle = $this.hasClass('dropdown-toggle'),
$parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU),
that = $parent.data('this'),
$items = that.findLis(),
index,
isActive,
liActive,
activeLi,
offset,
updateScroll = false,
downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab,
isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab,
scrollTop = that.$menuInner[0].scrollTop,
isVirtual = that.isVirtual(),
position0 = isVirtual === true ? that.selectpicker.view.position0 : 0;
// do nothing if a function key is pressed
if (e.which >= 112 && e.which <= 123) return;
isActive = that.$newElement.hasClass(classNames.SHOW);
if (
!isActive &&
(
isArrowKey ||
(e.which >= 48 && e.which <= 57) ||
(e.which >= 96 && e.which <= 105) ||
(e.which >= 65 && e.which <= 90)
)
) {
that.$button.trigger('click.bs.dropdown.data-api');
if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
return;
}
}
if (e.which === keyCodes.ESCAPE && isActive) {
e.preventDefault();
that.$button.trigger('click.bs.dropdown.data-api').trigger('focus');
}
if (isArrowKey) { // if up or down
if (!$items.length) return;
liActive = that.selectpicker.main.elements[that.activeIndex];
index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1;
if (index !== -1) {
that.defocusItem(liActive);
}
if (e.which === keyCodes.ARROW_UP) { // up
if (index !== -1) index--;
if (index + position0 < 0) index += $items.length;
if (!that.selectpicker.view.canHighlight[index + position0]) {
index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0;
if (index === -1) index = $items.length - 1;
}
} else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
index++;
if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0;
if (!that.selectpicker.view.canHighlight[index + position0]) {
index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true);
}
}
e.preventDefault();
var liActiveIndex = position0 + index;
if (e.which === keyCodes.ARROW_UP) { // up
// scroll to bottom and highlight last option
if (position0 === 0 && index === $items.length - 1) {
that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight;
liActiveIndex = that.selectpicker.current.elements.length - 1;
} else {
activeLi = that.selectpicker.current.data[liActiveIndex];
offset = activeLi.position - activeLi.height;
updateScroll = offset < scrollTop;
}
} else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
// scroll to top and highlight first option
if (index === 0) {
that.$menuInner[0].scrollTop = 0;
liActiveIndex = 0;
} else {
activeLi = that.selectpicker.current.data[liActiveIndex];
offset = activeLi.position - that.sizeInfo.menuInnerHeight;
updateScroll = offset > scrollTop;
}
}
liActive = that.selectpicker.current.elements[liActiveIndex];
that.activeIndex = that.selectpicker.current.data[liActiveIndex].index;
that.focusItem(liActive);
that.selectpicker.view.currentActive = liActive;
if (updateScroll) that.$menuInner[0].scrollTop = offset;
if (that.options.liveSearch) {
that.$searchbox.trigger('focus');
} else {
$this.trigger('focus');
}
} else if (
(!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) ||
(e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory)
) {
var searchMatch,
matches = [],
keyHistory;
e.preventDefault();
that.selectpicker.keydown.keyHistory += keyCodeMap[e.which];
if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel);
that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start();
keyHistory = that.selectpicker.keydown.keyHistory;
// if all letters are the same, set keyHistory to just the first character when searching
if (/^(.)\1+$/.test(keyHistory)) {
keyHistory = keyHistory.charAt(0);
}
// find matches
for (var i = 0; i < that.selectpicker.current.data.length; i++) {
var li = that.selectpicker.current.data[i],
hasMatch;
hasMatch = stringSearch(li, keyHistory, 'startsWith', true);
if (hasMatch && that.selectpicker.view.canHighlight[i]) {
matches.push(li.index);
}
}
if (matches.length) {
var matchIndex = 0;
$items.removeClass('active').find('a').removeClass('active');
// either only one key has been pressed or they are all the same key
if (keyHistory.length === 1) {
matchIndex = matches.indexOf(that.activeIndex);
if (matchIndex === -1 || matchIndex === matches.length - 1) {
matchIndex = 0;
} else {
matchIndex++;
}
}
searchMatch = matches[matchIndex];
activeLi = that.selectpicker.main.data[searchMatch];
if (scrollTop - activeLi.position > 0) {
offset = activeLi.position - activeLi.height;
updateScroll = true;
} else {
offset = activeLi.position - that.sizeInfo.menuInnerHeight;
// if the option is already visible at the current scroll position, just keep it the same
updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight;
}
liActive = that.selectpicker.main.elements[searchMatch];
that.activeIndex = matches[matchIndex];
that.focusItem(liActive);
if (liActive) liActive.firstChild.focus();
if (updateScroll) that.$menuInner[0].scrollTop = offset;
$this.trigger('focus');
}
}
// Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu.
if (
isActive &&
(
(e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) ||
e.which === keyCodes.ENTER ||
(e.which === keyCodes.TAB && that.options.selectOnTab)
)
) {
if (e.which !== keyCodes.SPACE) e.preventDefault();
if (!that.options.liveSearch || e.which !== keyCodes.SPACE) {
that.$menuInner.find('.active a').trigger('click', true); // retain active class
$this.trigger('focus');
if (!that.options.liveSearch) {
// Prevent screen from scrolling if the user hits the spacebar
e.preventDefault();
// Fixes spacebar selection of dropdown items in FF & IE
$(document).data('spaceSelect', true);
}
}
}
},
mobile: function () {
this.$element[0].classList.add('mobile-device');
},
refresh: function () {
// update options if data attributes have been changed
var config = $.extend({}, this.options, this.$element.data());
this.options = config;
this.checkDisabled();
this.setStyle();
this.render();
this.createLi();
this.setWidth();
this.setSize(true);
this.$element.trigger('refreshed' + EVENT_KEY);
},
hide: function () {
this.$newElement.hide();
},
show: function () {
this.$newElement.show();
},
remove: function () {
this.$newElement.remove();
this.$element.remove();
},
destroy: function () {
this.$newElement.before(this.$element).remove();
if (this.$bsContainer) {
this.$bsContainer.remove();
} else {
this.$menu.remove();
}
this.$element
.off(EVENT_KEY)
.removeData('selectpicker')
.removeClass('bs-select-hidden selectpicker');
$(window).off(EVENT_KEY + '.' + this.selectId);
}
};
// SELECTPICKER PLUGIN DEFINITION
// ==============================
function Plugin (option) {
// get the args of the outer function..
var args = arguments;
// The arguments of the function are explicitly re-defined from the argument list, because the shift causes them
// to get lost/corrupted in android 2.3 and IE9 #715 #775
var _option = option;
[].shift.apply(args);
// if the version was not set successfully
if (!version.success) {
// try to retreive it again
try {
version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
} catch (err) {
// fall back to use BootstrapVersion if set
if (Selectpicker.BootstrapVersion) {
version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.');
} else {
version.full = [version.major, '0', '0'];
console.warn(
'There was an issue retrieving Bootstrap\'s version. ' +
'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' +
'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.',
err
);
}
}
version.major = version.full[0];
version.success = true;
}
if (version.major === '4') {
// some defaults need to be changed if using Bootstrap 4
// check to see if they have already been manually changed before forcing them to update
var toUpdate = [];
if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' });
if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' });
if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' });
classNames.DIVIDER = 'dropdown-divider';
classNames.SHOW = 'show';
classNames.BUTTONCLASS = 'btn-light';
classNames.POPOVERHEADER = 'popover-header';
classNames.ICONBASE = '';
classNames.TICKICON = 'bs-ok-default';
for (var i = 0; i < toUpdate.length; i++) {
var option = toUpdate[i];
Selectpicker.DEFAULTS[option.name] = classNames[option.className];
}
}
var value;
var chain = this.each(function () {
var $this = $(this);
if ($this.is('select')) {
var data = $this.data('selectpicker'),
options = typeof _option == 'object' && _option;
if (!data) {
var dataAttributes = $this.data();
for (var dataAttr in dataAttributes) {
if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
delete dataAttributes[dataAttr];
}
}
var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options);
config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template);
$this.data('selectpicker', (data = new Selectpicker(this, config)));
} else if (options) {
for (var i in options) {
if (options.hasOwnProperty(i)) {
data.options[i] = options[i];
}
}
}
if (typeof _option == 'string') {
if (data[_option] instanceof Function) {
value = data[_option].apply(data, args);
} else {
value = data.options[_option];
}
}
}
});
if (typeof value !== 'undefined') {
// noinspection JSUnusedAssignment
return value;
} else {
return chain;
}
}
var old = $.fn.selectpicker;
$.fn.selectpicker = Plugin;
$.fn.selectpicker.Constructor = Selectpicker;
// SELECTPICKER NO CONFLICT
// ========================
$.fn.selectpicker.noConflict = function () {
$.fn.selectpicker = old;
return this;
};
$(document)
.off('keydown.bs.dropdown.data-api', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select .dropdown-menu')
.on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
.on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
e.stopPropagation();
});
// SELECTPICKER DATA-API
// =====================
$(window).on('load' + EVENT_KEY + '.data-api', function () {
$('.selectpicker').each(function () {
var $selectpicker = $(this);
Plugin.call($selectpicker, $selectpicker.data());
})
});
})(jQuery);
}));
//# sourceMappingURL=bootstrap-select.js.map
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(jQuery) {/* ========================================================================
* Bootstrap (plugin): validator.js v0.11.9
* ========================================================================
* The MIT License (MIT)
*
* Copyright (c) 2016 Cina Saffary.
* Made by @1000hz in the style of Bootstrap 3 era @fat
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* ======================================================================== */
+function ($) {
'use strict';
// VALIDATOR CLASS DEFINITION
// ==========================
function getValue($el) {
return $el.is('[type="checkbox"]') ? $el.prop('checked') :
$el.is('[type="radio"]') ? !!$('[name="' + $el.attr('name') + '"]:checked').length :
$el.is('select[multiple]') ? ($el.val() || []).length :
$el.val()
}
var Validator = function (element, options) {
this.options = options
this.validators = $.extend({}, Validator.VALIDATORS, options.custom)
this.$element = $(element)
this.$btn = $('button[type="submit"], input[type="submit"]')
.filter('[form="' + this.$element.attr('id') + '"]')
.add(this.$element.find('input[type="submit"], button[type="submit"]'))
this.update()
this.$element.on('input.bs.validator change.bs.validator focusout.bs.validator', $.proxy(this.onInput, this))
this.$element.on('submit.bs.validator', $.proxy(this.onSubmit, this))
this.$element.on('reset.bs.validator', $.proxy(this.reset, this))
this.$element.find('[data-match]').each(function () {
var $this = $(this)
var target = $this.attr('data-match')
$(target).on('input.bs.validator', function (e) {
getValue($this) && $this.trigger('input.bs.validator')
})
})
// run validators for fields with values, but don't clobber server-side errors
this.$inputs.filter(function () {
return getValue($(this)) && !$(this).closest('.has-error').length
}).trigger('focusout')
this.$element.attr('novalidate', true) // disable automatic native validation
}
Validator.VERSION = '0.11.9'
Validator.INPUT_SELECTOR = ':input:not([type="hidden"], [type="submit"], [type="reset"], button)'
Validator.FOCUS_OFFSET = 20
Validator.DEFAULTS = {
delay: 500,
html: false,
disable: true,
focus: true,
custom: {},
errors: {
match: 'Does not match',
minlength: 'Not long enough'
},
feedback: {
success: 'glyphicon-ok',
error: 'glyphicon-remove'
}
}
Validator.VALIDATORS = {
'native': function ($el) {
var el = $el[0]
if (el.checkValidity) {
return !el.checkValidity() && !el.validity.valid && (el.validationMessage || "error!")
}
},
'match': function ($el) {
var target = $el.attr('data-match')
return $el.val() !== $(target).val() && Validator.DEFAULTS.errors.match
},
'minlength': function ($el) {
var minlength = $el.attr('data-minlength')
return $el.val().length < minlength && Validator.DEFAULTS.errors.minlength
}
}
Validator.prototype.update = function () {
var self = this
this.$inputs = this.$element.find(Validator.INPUT_SELECTOR)
.add(this.$element.find('[data-validate="true"]'))
.not(this.$element.find('[data-validate="false"]')
.each(function () { self.clearErrors($(this)) })
)
this.toggleSubmit()
return this
}
Validator.prototype.onInput = function (e) {
var self = this
var $el = $(e.target)
var deferErrors = e.type !== 'focusout'
if (!this.$inputs.is($el)) return
this.validateInput($el, deferErrors).done(function () {
self.toggleSubmit()
})
}
Validator.prototype.validateInput = function ($el, deferErrors) {
var value = getValue($el)
var prevErrors = $el.data('bs.validator.errors')
if ($el.is('[type="radio"]')) $el = this.$element.find('input[name="' + $el.attr('name') + '"]')
var e = $.Event('validate.bs.validator', {relatedTarget: $el[0]})
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
var self = this
return this.runValidators($el).done(function (errors) {
$el.data('bs.validator.errors', errors)
errors.length
? deferErrors ? self.defer($el, self.showErrors) : self.showErrors($el)
: self.clearErrors($el)
if (!prevErrors || errors.toString() !== prevErrors.toString()) {
e = errors.length
? $.Event('invalid.bs.validator', {relatedTarget: $el[0], detail: errors})
: $.Event('valid.bs.validator', {relatedTarget: $el[0], detail: prevErrors})
self.$element.trigger(e)
}
self.toggleSubmit()
self.$element.trigger($.Event('validated.bs.validator', {relatedTarget: $el[0]}))
})
}
Validator.prototype.runValidators = function ($el) {
var errors = []
var deferred = $.Deferred()
$el.data('bs.validator.deferred') && $el.data('bs.validator.deferred').reject()
$el.data('bs.validator.deferred', deferred)
function getValidatorSpecificError(key) {
return $el.attr('data-' + key + '-error')
}
function getValidityStateError() {
var validity = $el[0].validity
return validity.typeMismatch ? $el.attr('data-type-error')
: validity.patternMismatch ? $el.attr('data-pattern-error')
: validity.stepMismatch ? $el.attr('data-step-error')
: validity.rangeOverflow ? $el.attr('data-max-error')
: validity.rangeUnderflow ? $el.attr('data-min-error')
: validity.valueMissing ? $el.attr('data-required-error')
: null
}
function getGenericError() {
return $el.attr('data-error')
}
function getErrorMessage(key) {
return getValidatorSpecificError(key)
|| getValidityStateError()
|| getGenericError()
}
$.each(this.validators, $.proxy(function (key, validator) {
var error = null
if ((getValue($el) || $el.attr('required')) &&
($el.attr('data-' + key) !== undefined || key == 'native') &&
(error = validator.call(this, $el))) {
error = getErrorMessage(key) || error
!~errors.indexOf(error) && errors.push(error)
}
}, this))
if (!errors.length && getValue($el) && $el.attr('data-remote')) {
this.defer($el, function () {
var data = {}
data[$el.attr('name')] = getValue($el)
$.get($el.attr('data-remote'), data)
.fail(function (jqXHR, textStatus, error) { errors.push(getErrorMessage('remote') || error) })
.always(function () { deferred.resolve(errors)})
})
} else deferred.resolve(errors)
return deferred.promise()
}
Validator.prototype.validate = function () {
var self = this
$.when(this.$inputs.map(function (el) {
return self.validateInput($(this), false)
})).then(function () {
self.toggleSubmit()
self.focusError()
})
return this
}
Validator.prototype.focusError = function () {
if (!this.options.focus) return
var $input = this.$element.find(".has-error:first :input")
if ($input.length === 0) return
$('html, body').animate({scrollTop: $input.offset().top - Validator.FOCUS_OFFSET}, 250)
$input.focus()
}
Validator.prototype.showErrors = function ($el) {
var method = this.options.html ? 'html' : 'text'
var errors = $el.data('bs.validator.errors')
var $group = $el.closest('.form-group')
var $block = $group.find('.help-block.with-errors')
var $feedback = $group.find('.form-control-feedback')
if (!errors.length) return
errors = $('<ul/>')
.addClass('list-unstyled')
.append($.map(errors, function (error) { return $('<li/>')[method](error) }))
$block.data('bs.validator.originalContent') === undefined && $block.data('bs.validator.originalContent', $block.html())
$block.empty().append(errors)
$group.addClass('has-error has-danger')
$group.hasClass('has-feedback')
&& $feedback.removeClass(this.options.feedback.success)
&& $feedback.addClass(this.options.feedback.error)
&& $group.removeClass('has-success')
}
Validator.prototype.clearErrors = function ($el) {
var $group = $el.closest('.form-group')
var $block = $group.find('.help-block.with-errors')
var $feedback = $group.find('.form-control-feedback')
$block.html($block.data('bs.validator.originalContent'))
$group.removeClass('has-error has-danger has-success')
$group.hasClass('has-feedback')
&& $feedback.removeClass(this.options.feedback.error)
&& $feedback.removeClass(this.options.feedback.success)
&& getValue($el)
&& $feedback.addClass(this.options.feedback.success)
&& $group.addClass('has-success')
}
Validator.prototype.hasErrors = function () {
function fieldErrors() {
return !!($(this).data('bs.validator.errors') || []).length
}
return !!this.$inputs.filter(fieldErrors).length
}
Validator.prototype.isIncomplete = function () {
function fieldIncomplete() {
var value = getValue($(this))
return !(typeof value == "string" ? $.trim(value) : value)
}
return !!this.$inputs.filter('[required]').filter(fieldIncomplete).length
}
Validator.prototype.onSubmit = function (e) {
this.validate()
if (this.isIncomplete() || this.hasErrors()) e.preventDefault()
}
Validator.prototype.toggleSubmit = function () {
if (!this.options.disable) return
this.$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())
}
Validator.prototype.defer = function ($el, callback) {
callback = $.proxy(callback, this, $el)
if (!this.options.delay) return callback()
window.clearTimeout($el.data('bs.validator.timeout'))
$el.data('bs.validator.timeout', window.setTimeout(callback, this.options.delay))
}
Validator.prototype.reset = function () {
this.$element.find('.form-control-feedback')
.removeClass(this.options.feedback.error)
.removeClass(this.options.feedback.success)
this.$inputs
.removeData(['bs.validator.errors', 'bs.validator.deferred'])
.each(function () {
var $this = $(this)
var timeout = $this.data('bs.validator.timeout')
window.clearTimeout(timeout) && $this.removeData('bs.validator.timeout')
})
this.$element.find('.help-block.with-errors')
.each(function () {
var $this = $(this)
var originalContent = $this.data('bs.validator.originalContent')
$this
.removeData('bs.validator.originalContent')
.html(originalContent)
})
this.$btn.removeClass('disabled')
this.$element.find('.has-error, .has-danger, .has-success').removeClass('has-error has-danger has-success')
return this
}
Validator.prototype.destroy = function () {
this.reset()
this.$element
.removeAttr('novalidate')
.removeData('bs.validator')
.off('.bs.validator')
this.$inputs
.off('.bs.validator')
this.options = null
this.validators = null
this.$element = null
this.$btn = null
this.$inputs = null
return this
}
// VALIDATOR PLUGIN DEFINITION
// ===========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var options = $.extend({}, Validator.DEFAULTS, $this.data(), typeof option == 'object' && option)
var data = $this.data('bs.validator')
if (!data && option == 'destroy') return
if (!data) $this.data('bs.validator', (data = new Validator(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.validator
$.fn.validator = Plugin
$.fn.validator.Constructor = Validator
// VALIDATOR NO CONFLICT
// =====================
$.fn.validator.noConflict = function () {
$.fn.validator = old
return this
}
// VALIDATOR DATA-API
// ==================
$(window).on('load', function () {
$('form[data-toggle="validator"]').each(function () {
var $form = $(this)
Plugin.call($form, $form.data())
})
})
}(jQuery);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* bootstrap-fileinput v4.5.3
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
* Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com
*
* Licensed under the BSD-3-Clause
* https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
*/
(function (factory) {
'use strict';
//noinspection JSUnresolvedVariable
if (true) { // jshint ignore:line
// AMD. Register as an anonymous module.
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(0)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); // jshint ignore:line
} else { // noinspection JSUnresolvedVariable
if (typeof module === 'object' && module.exports) { // jshint ignore:line
// Node/CommonJS
// noinspection JSUnresolvedVariable
module.exports = factory(require('jquery')); // jshint ignore:line
} else {
// Browser globals
factory(window.jQuery);
}
}
}(function ($) {
'use strict';
$.fn.fileinputLocales = {};
$.fn.fileinputThemes = {};
String.prototype.setTokens = function (replacePairs) {
var str = this.toString(), key, re;
for (key in replacePairs) {
if (replacePairs.hasOwnProperty(key)) {
re = new RegExp('\{' + key + '\}', 'g');
str = str.replace(re, replacePairs[key]);
}
}
return str;
};
var $h, FileInput;
// fileinput helper object for all global variables and internal helper methods
//noinspection JSUnresolvedVariable
$h = {
FRAMES: '.kv-preview-thumb',
SORT_CSS: 'file-sortable',
OBJECT_PARAMS: '<param name="controller" value="true" />\n' +
'<param name="allowFullScreen" value="true" />\n' +
'<param name="allowScriptAccess" value="always" />\n' +
'<param name="autoPlay" value="false" />\n' +
'<param name="autoStart" value="false" />\n' +
'<param name="quality" value="high" />\n',
DEFAULT_PREVIEW: '<div class="file-preview-other">\n' +
'<span class="{previewFileIconClass}">{previewFileIcon}</span>\n' +
'</div>',
MODAL_ID: 'kvFileinputModal',
MODAL_EVENTS: ['show', 'shown', 'hide', 'hidden', 'loaded'],
objUrl: window.URL || window.webkitURL,
now: function () {
return new Date();
},
stopEvent: function (e) {
e.stopPropagation();
e.preventDefault();
},
getFileName: function (file) {
/** @namespace file.fileName */
return file ? (file.fileName || file.name || '') : ''; // some confusion in different versions of Firefox
},
createObjectURL: function (data) {
if ($h.objUrl && $h.objUrl.createObjectURL && data) {
return $h.objUrl.createObjectURL(data);
}
return '';
},
revokeObjectURL: function (data) {
if ($h.objUrl && $h.objUrl.revokeObjectURL && data) {
$h.objUrl.revokeObjectURL(data);
}
},
compare: function (input, str, exact) {
return input !== undefined && (exact ? input === str : input.match(str));
},
isIE: function (ver) {
var div, status;
// check for IE versions < 11
if (navigator.appName !== 'Microsoft Internet Explorer') {
return false;
}
if (ver === 10) {
return new RegExp('msie\\s' + ver, 'i').test(navigator.userAgent);
}
div = document.createElement('div');
div.innerHTML = '<!--[if IE ' + ver + ']> <i></i> <![endif]-->';
status = div.getElementsByTagName('i').length;
document.body.appendChild(div);
div.parentNode.removeChild(div);
return status;
},
canAssignFilesToInput: function () {
var input = document.createElement('input');
try {
input.type = 'file';
input.files = null;
return true;
} catch (err) {
return false;
}
},
getDragDropFolders: function (items) {
var i, item, len = items ? items.length : 0, folders = 0;
if (len > 0 && items[0].webkitGetAsEntry()) {
for (i = 0; i < len; i++) {
item = items[i].webkitGetAsEntry();
if (item && item.isDirectory) {
folders++;
}
}
}
return folders;
},
initModal: function ($modal) {
var $body = $('body');
if ($body.length) {
$modal.appendTo($body);
}
},
isEmpty: function (value, trim) {
return value === undefined || value === null || value.length === 0 || (trim && $.trim(value) === '');
},
isArray: function (a) {
return Array.isArray(a) || Object.prototype.toString.call(a) === '[object Array]';
},
ifSet: function (needle, haystack, def) {
def = def || '';
return (haystack && typeof haystack === 'object' && needle in haystack) ? haystack[needle] : def;
},
cleanArray: function (arr) {
if (!(arr instanceof Array)) {
arr = [];
}
return arr.filter(function (e) {
return (e !== undefined && e !== null);
});
},
spliceArray: function (arr, index, reverseOrder) {
var i, j = 0, out = [], newArr;
if (!(arr instanceof Array)) {
return [];
}
newArr = $.extend(true, [], arr);
if (reverseOrder) {
newArr.reverse();
}
for (i = 0; i < newArr.length; i++) {
if (i !== index) {
out[j] = newArr[i];
j++;
}
}
if (reverseOrder) {
out.reverse();
}
return out;
},
getNum: function (num, def) {
def = def || 0;
if (typeof num === 'number') {
return num;
}
if (typeof num === 'string') {
num = parseFloat(num);
}
return isNaN(num) ? def : num;
},
hasFileAPISupport: function () {
return !!(window.File && window.FileReader);
},
hasDragDropSupport: function () {
var div = document.createElement('div');
/** @namespace div.draggable */
/** @namespace div.ondragstart */
/** @namespace div.ondrop */
return !$h.isIE(9) &&
(div.draggable !== undefined || (div.ondragstart !== undefined && div.ondrop !== undefined));
},
hasFileUploadSupport: function () {
return $h.hasFileAPISupport() && window.FormData;
},
hasBlobSupport: function () {
try {
return !!window.Blob && Boolean(new Blob());
} catch (e) {
return false;
}
},
hasArrayBufferViewSupport: function () {
try {
return new Blob([new Uint8Array(100)]).size === 100;
} catch (e) {
return false;
}
},
dataURI2Blob: function (dataURI) {
//noinspection JSUnresolvedVariable
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder ||
window.MSBlobBuilder, canBlob = $h.hasBlobSupport(), byteStr, arrayBuffer, intArray, i, mimeStr, bb,
canProceed = (canBlob || BlobBuilder) && window.atob && window.ArrayBuffer && window.Uint8Array;
if (!canProceed) {
return null;
}
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
byteStr = atob(dataURI.split(',')[1]);
} else {
byteStr = decodeURIComponent(dataURI.split(',')[1]);
}
arrayBuffer = new ArrayBuffer(byteStr.length);
intArray = new Uint8Array(arrayBuffer);
for (i = 0; i < byteStr.length; i += 1) {
intArray[i] = byteStr.charCodeAt(i);
}
mimeStr = dataURI.split(',')[0].split(':')[1].split(';')[0];
if (canBlob) {
return new Blob([$h.hasArrayBufferViewSupport() ? intArray : arrayBuffer], {type: mimeStr});
}
bb = new BlobBuilder();
bb.append(arrayBuffer);
return bb.getBlob(mimeStr);
},
arrayBuffer2String: function (buffer) {
//noinspection JSUnresolvedVariable
if (window.TextDecoder) {
// noinspection JSUnresolvedFunction
return new TextDecoder('utf-8').decode(buffer);
}
var array = Array.prototype.slice.apply(new Uint8Array(buffer)), out = '', i = 0, len, c, char2, char3;
len = array.length;
while (i < len) {
c = array[i++];
switch (c >> 4) { // jshint ignore:line
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
// 0xxxxxxx
out += String.fromCharCode(c);
break;
case 12:
case 13:
// 110x xxxx 10xx xxxx
char2 = array[i++];
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); // jshint ignore:line
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = array[i++];
char3 = array[i++];
out += String.fromCharCode(((c & 0x0F) << 12) | // jshint ignore:line
((char2 & 0x3F) << 6) | // jshint ignore:line
((char3 & 0x3F) << 0)); // jshint ignore:line
break;
}
}
return out;
},
isHtml: function (str) {
var a = document.createElement('div');
a.innerHTML = str;
for (var c = a.childNodes, i = c.length; i--;) {
if (c[i].nodeType === 1) {
return true;
}
}
return false;
},
isSvg: function (str) {
return str.match(/^\s*<\?xml/i) && (str.match(/<!DOCTYPE svg/i) || str.match(/<svg/i));
},
getMimeType: function (signature, contents, type) {
switch (signature) {
case 'ffd8ffe0':
case 'ffd8ffe1':
case 'ffd8ffe2':
return 'image/jpeg';
case '89504E47':
return 'image/png';
case '47494638':
return 'image/gif';
case '49492a00':
return 'image/tiff';
case '52494646':
return 'image/webp';
case '66747970':
return 'video/3gp';
case '4f676753':
return 'video/ogg';
case '1a45dfa3':
return 'video/mkv';
case '000001ba':
case '000001b3':
return 'video/mpeg';
case '3026b275':
return 'video/wmv';
case '25504446':
return 'application/pdf';
case '25215053':
return 'application/ps';
case '504b0304':
case '504b0506':
case '504b0508':
return 'application/zip';
case '377abcaf':
return 'application/7z';
case '75737461':
return 'application/tar';
case '7801730d':
return 'application/dmg';
default:
switch (signature.substring(0, 6)) {
case '435753':
return 'application/x-shockwave-flash';
case '494433':
return 'audio/mp3';
case '425a68':
return 'application/bzip';
default:
switch (signature.substring(0, 4)) {
case '424d':
return 'image/bmp';
case 'fffb':
return 'audio/mp3';
case '4d5a':
return 'application/exe';
case '1f9d':
case '1fa0':
return 'application/zip';
case '1f8b':
return 'application/gzip';
default:
return contents && !contents.match(
/[^\u0000-\u007f]/) ? 'application/text-plain' : type;
}
}
}
},
addCss: function ($el, css) {
$el.removeClass(css).addClass(css);
},
getElement: function (options, param, value) {
return ($h.isEmpty(options) || $h.isEmpty(options[param])) ? value : $(options[param]);
},
uniqId: function () {
return Math.round(new Date().getTime()) + '_' + Math.round(Math.random() * 100);
},
htmlEncode: function (str, undefVal) {
if (str === undefined) {
return undefVal || null;
}
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
},
replaceTags: function (str, tags) {
var out = str;
if (!tags) {
return out;
}
$.each(tags, function (key, value) {
if (typeof value === 'function') {
value = value();
}
out = out.split(key).join(value);
});
return out;
},
cleanMemory: function ($thumb) {
var data = $thumb.is('img') ? $thumb.attr('src') : $thumb.find('source').attr('src');
$h.revokeObjectURL(data);
},
findFileName: function (filePath) {
var sepIndex = filePath.lastIndexOf('/');
if (sepIndex === -1) {
sepIndex = filePath.lastIndexOf('\\');
}
return filePath.split(filePath.substring(sepIndex, sepIndex + 1)).pop();
},
checkFullScreen: function () {
//noinspection JSUnresolvedVariable
return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement ||
document.msFullscreenElement;
},
toggleFullScreen: function (maximize) {
var doc = document, de = doc.documentElement;
if (de && maximize && !$h.checkFullScreen()) {
/** @namespace document.requestFullscreen */
/** @namespace document.msRequestFullscreen */
/** @namespace document.mozRequestFullScreen */
/** @namespace document.webkitRequestFullscreen */
/** @namespace Element.ALLOW_KEYBOARD_INPUT */
if (de.requestFullscreen) {
de.requestFullscreen();
} else {
if (de.msRequestFullscreen) {
de.msRequestFullscreen();
} else {
if (de.mozRequestFullScreen) {
de.mozRequestFullScreen();
} else {
if (de.webkitRequestFullscreen) {
de.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
}
}
} else {
/** @namespace document.exitFullscreen */
/** @namespace document.msExitFullscreen */
/** @namespace document.mozCancelFullScreen */
/** @namespace document.webkitExitFullscreen */
if (doc.exitFullscreen) {
doc.exitFullscreen();
} else {
if (doc.msExitFullscreen) {
doc.msExitFullscreen();
} else {
if (doc.mozCancelFullScreen) {
doc.mozCancelFullScreen();
} else {
if (doc.webkitExitFullscreen) {
doc.webkitExitFullscreen();
}
}
}
}
}
},
moveArray: function (arr, oldIndex, newIndex, reverseOrder) {
var newArr = $.extend(true, [], arr);
if (reverseOrder) {
newArr.reverse();
}
if (newIndex >= newArr.length) {
var k = newIndex - newArr.length;
while ((k--) + 1) {
newArr.push(undefined);
}
}
newArr.splice(newIndex, 0, newArr.splice(oldIndex, 1)[0]);
if (reverseOrder) {
newArr.reverse();
}
return newArr;
},
cleanZoomCache: function ($el) {
var $cache = $el.closest('.kv-zoom-cache-theme');
if (!$cache.length) {
$cache = $el.closest('.kv-zoom-cache');
}
$cache.remove();
},
closeButton: function (css) {
css = css ? 'close ' + css : 'close';
return '<button type="button" class="' + css + '" aria-label="Close">\n' +
' <span aria-hidden="true">&times;</span>\n' +
'</button>';
},
getRotation: function (value) {
switch (value) {
case 2:
return 'rotateY(180deg)';
case 3:
return 'rotate(180deg)';
case 4:
return 'rotate(180deg) rotateY(180deg)';
case 5:
return 'rotate(270deg) rotateY(180deg)';
case 6:
return 'rotate(90deg)';
case 7:
return 'rotate(90deg) rotateY(180deg)';
case 8:
return 'rotate(270deg)';
default:
return '';
}
},
setTransform: function (el, val) {
if (!el) {
return;
}
el.style.transform = val;
el.style.webkitTransform = val;
el.style['-moz-transform'] = val;
el.style['-ms-transform'] = val;
el.style['-o-transform'] = val;
},
setImageOrientation: function ($img, $zoomImg, value) {
if (!$img || !$img.length) {
return;
}
var ev = 'load.fileinputimageorient';
$img.off(ev).on(ev, function () {
var img = $img.get(0), zoomImg = $zoomImg && $zoomImg.length ? $zoomImg.get(0) : null,
h = img.offsetHeight, w = img.offsetWidth, r = $h.getRotation(value);
$img.data('orientation', value);
if (zoomImg) {
$zoomImg.data('orientation', value);
}
if (value < 5) {
$h.setTransform(img, r);
$h.setTransform(zoomImg, r);
return;
}
var offsetAngle = Math.atan(w / h), origFactor = Math.sqrt(Math.pow(h, 2) + Math.pow(w, 2)),
scale = !origFactor ? 1 : (h / Math.cos(Math.PI / 2 + offsetAngle)) / origFactor,
s = ' scale(' + Math.abs(scale) + ')';
$h.setTransform(img, r + s);
$h.setTransform(zoomImg, r + s);
});
}
};
FileInput = function (element, options) {
var self = this;
self.$element = $(element);
self.$parent = self.$element.parent();
if (!self._validate()) {
return;
}
self.isPreviewable = $h.hasFileAPISupport();
self.isIE9 = $h.isIE(9);
self.isIE10 = $h.isIE(10);
if (self.isPreviewable || self.isIE9) {
self._init(options);
self._listen();
}
self.$element.removeClass('file-loading');
};
//noinspection JSUnusedGlobalSymbols
FileInput.prototype = {
constructor: FileInput,
_cleanup: function () {
var self = this;
self.reader = null;
self.formdata = {};
self.uploadCount = 0;
self.uploadStatus = {};
self.uploadLog = [];
self.uploadAsyncCount = 0;
self.loadedImages = [];
self.totalImagesCount = 0;
self.ajaxRequests = [];
self.clearStack();
self.fileBatchCompleted = true;
if (!self.isPreviewable) {
self.showPreview = false;
}
self.isError = false;
self.ajaxAborted = false;
self.cancelling = false;
},
_init: function (options, refreshMode) {
var self = this, f, $el = self.$element, $cont, t, tmp;
self.options = options;
$.each(options, function (key, value) {
switch (key) {
case 'minFileCount':
case 'maxFileCount':
case 'minFileSize':
case 'maxFileSize':
case 'maxFilePreviewSize':
case 'resizeImageQuality':
case 'resizeIfSizeMoreThan':
case 'progressUploadThreshold':
case 'initialPreviewCount':
case 'zoomModalHeight':
case 'minImageHeight':
case 'maxImageHeight':
case 'minImageWidth':
case 'maxImageWidth':
self[key] = $h.getNum(value);
break;
default:
self[key] = value;
break;
}
});
if (self.rtl) { // swap buttons for rtl
tmp = self.previewZoomButtonIcons.prev;
self.previewZoomButtonIcons.prev = self.previewZoomButtonIcons.next;
self.previewZoomButtonIcons.next = tmp;
}
if (!refreshMode) {
self._cleanup();
}
self.$form = $el.closest('form');
self._initTemplateDefaults();
self.uploadFileAttr = !$h.isEmpty($el.attr('name')) ? $el.attr('name') : 'file_data';
t = self._getLayoutTemplate('progress');
self.progressTemplate = t.replace('{class}', self.progressClass);
self.progressCompleteTemplate = t.replace('{class}', self.progressCompleteClass);
self.progressErrorTemplate = t.replace('{class}', self.progressErrorClass);
self.isDisabled = $el.attr('disabled') || $el.attr('readonly');
if (self.isDisabled) {
$el.attr('disabled', true);
}
self.isClickable = self.browseOnZoneClick && self.showPreview &&
(self.dropZoneEnabled || !$h.isEmpty(self.defaultPreviewContent));
self.isAjaxUpload = $h.hasFileUploadSupport() && !$h.isEmpty(self.uploadUrl);
self.dropZoneEnabled = $h.hasDragDropSupport() && self.dropZoneEnabled;
if (!self.isAjaxUpload) {
self.dropZoneEnabled = self.dropZoneEnabled && $h.canAssignFilesToInput();
}
self.slug = typeof options.slugCallback === 'function' ? options.slugCallback : self._slugDefault;
self.mainTemplate = self.showCaption ? self._getLayoutTemplate('main1') : self._getLayoutTemplate('main2');
self.captionTemplate = self._getLayoutTemplate('caption');
self.previewGenericTemplate = self._getPreviewTemplate('generic');
if (!self.imageCanvas && self.resizeImage && (self.maxImageWidth || self.maxImageHeight)) {
self.imageCanvas = document.createElement('canvas');
self.imageCanvasContext = self.imageCanvas.getContext('2d');
}
if ($h.isEmpty($el.attr('id'))) {
$el.attr('id', $h.uniqId());
}
self.namespace = '.fileinput_' + $el.attr('id').replace(/-/g, '_');
if (self.$container === undefined) {
self.$container = self._createContainer();
} else {
self._refreshContainer();
}
$cont = self.$container;
self.$dropZone = $cont.find('.file-drop-zone');
self.$progress = $cont.find('.kv-upload-progress');
self.$btnUpload = $cont.find('.fileinput-upload');
self.$captionContainer = $h.getElement(options, 'elCaptionContainer', $cont.find('.file-caption'));
self.$caption = $h.getElement(options, 'elCaptionText', $cont.find('.file-caption-name'));
if (!$h.isEmpty(self.msgPlaceholder)) {
f = $el.attr('multiple') ? self.filePlural : self.fileSingle;
self.$caption.attr('placeholder', self.msgPlaceholder.replace('{files}', f));
}
self.$captionIcon = self.$captionContainer.find('.file-caption-icon');
self.$previewContainer = $h.getElement(options, 'elPreviewContainer', $cont.find('.file-preview'));
self.$preview = $h.getElement(options, 'elPreviewImage', $cont.find('.file-preview-thumbnails'));
self.$previewStatus = $h.getElement(options, 'elPreviewStatus', $cont.find('.file-preview-status'));
self.$errorContainer = $h.getElement(options, 'elErrorContainer',
self.$previewContainer.find('.kv-fileinput-error'));
self._validateDisabled();
if (!$h.isEmpty(self.msgErrorClass)) {
$h.addCss(self.$errorContainer, self.msgErrorClass);
}
if (!refreshMode) {
self.$errorContainer.hide();
self.previewInitId = 'preview-' + $h.uniqId();
self._initPreviewCache();
self._initPreview(true);
self._initPreviewActions();
if (self.$parent.hasClass('file-loading')) {
self.$container.insertBefore(self.$parent);
self.$parent.remove();
}
} else {
if (!self._errorsExist()) {
self.$errorContainer.hide();
}
}
self._setFileDropZoneTitle();
if ($el.attr('disabled')) {
self.disable();
}
self._initZoom();
if (self.hideThumbnailContent) {
$h.addCss(self.$preview, 'hide-content');
}
},
_initTemplateDefaults: function () {
var self = this, tMain1, tMain2, tPreview, tFileIcon, tClose, tCaption, tBtnDefault, tBtnLink, tBtnBrowse,
tModalMain, tModal, tProgress, tSize, tFooter, tActions, tActionDelete, tActionUpload, tActionDownload,
tActionZoom, tActionDrag, tIndicator, tTagBef, tTagBef1, tTagBef2, tTagAft, tGeneric, tHtml, tImage,
tText, tOffice, tGdocs, tVideo, tAudio, tFlash, tObject, tPdf, tOther, tStyle, tZoomCache, vDefaultDim;
tMain1 = '{preview}\n' +
'<div class="kv-upload-progress kv-hidden"></div><div class="clearfix"></div>\n' +
'<div class="input-group {class}">\n' +
' {caption}\n' +
'<div class="input-group-btn input-group-append">\n' +
' {remove}\n' +
' {cancel}\n' +
' {upload}\n' +
' {browse}\n' +
' </div>\n' +
'</div>';
tMain2 = '{preview}\n<div class="kv-upload-progress kv-hidden"></div>\n<div class="clearfix"></div>\n' +
'{remove}\n{cancel}\n{upload}\n{browse}\n';
tPreview = '<div class="file-preview {class}">\n' +
' {close}' +
' <div class="{dropClass}">\n' +
' <div class="file-preview-thumbnails">\n' +
' </div>\n' +
' <div class="clearfix"></div>' +
' <div class="file-preview-status text-center text-success"></div>\n' +
' <div class="kv-fileinput-error"></div>\n' +
' </div>\n' +
'</div>';
tClose = $h.closeButton('fileinput-remove');
tFileIcon = '<i class="glyphicon glyphicon-file"></i>';
// noinspection HtmlUnknownAttribute
tCaption = '<div class="file-caption form-control {class}" tabindex="500">\n' +
' <span class="file-caption-icon"></span>\n' +
' <input class="file-caption-name" onkeydown="return false;" onpaste="return false;">\n' +
'</div>';
//noinspection HtmlUnknownAttribute
tBtnDefault = '<button type="{type}" tabindex="500" title="{title}" class="{css}" ' +
'{status}>{icon} {label}</button>';
//noinspection HtmlUnknownAttribute
tBtnLink = '<a href="{href}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</a>';
//noinspection HtmlUnknownAttribute
tBtnBrowse = '<div tabindex="500" class="{css}" {status}>{icon} {label}</div>';
tModalMain = '<div id="' + $h.MODAL_ID + '" class="file-zoom-dialog modal fade" ' +
'tabindex="-1" aria-labelledby="' + $h.MODAL_ID + 'Label"></div>';
tModal = '<div class="modal-dialog modal-lg{rtl}" role="document">\n' +
' <div class="modal-content">\n' +
' <div class="modal-header">\n' +
' <h5 class="modal-title">{heading}</h5>\n' +
' <span class="kv-zoom-title"></span>\n' +
' <div class="kv-zoom-actions">{toggleheader}{fullscreen}{borderless}{close}</div>\n' +
' </div>\n' +
' <div class="modal-body">\n' +
' <div class="floating-buttons"></div>\n' +
' <div class="kv-zoom-body file-zoom-content {zoomFrameClass}"></div>\n' + '{prev} {next}\n' +
' </div>\n' +
' </div>\n' +
'</div>\n';
tProgress = '<div class="progress">\n' +
' <div class="{class}" role="progressbar"' +
' aria-valuenow="{percent}" aria-valuemin="0" aria-valuemax="100" style="width:{percent}%;">\n' +
' {status}\n' +
' </div>\n' +
'</div>';
tSize = ' <samp>({sizeText})</samp>';
tFooter = '<div class="file-thumbnail-footer">\n' +
' <div class="file-footer-caption" title="{caption}">\n' +
' <div class="file-caption-info">{caption}</div>\n' +
' <div class="file-size-info">{size}</div>\n' +
' </div>\n' +
' {progress}\n{indicator}\n{actions}\n' +
'</div>';
tActions = '<div class="file-actions">\n' +
' <div class="file-footer-buttons">\n' +
' {download} {upload} {delete} {zoom} {other}' +
' </div>\n' +
'</div>\n' +
'{drag}\n' +
'<div class="clearfix"></div>';
//noinspection HtmlUnknownAttribute
tActionDelete = '<button type="button" class="kv-file-remove {removeClass}" ' +
'title="{removeTitle}" {dataUrl}{dataKey}>{removeIcon}</button>\n';
tActionUpload = '<button type="button" class="kv-file-upload {uploadClass}" title="{uploadTitle}">' +
'{uploadIcon}</button>';
tActionDownload = '<a class="kv-file-download {downloadClass}" title="{downloadTitle}" ' +
'href="{downloadUrl}" download="{caption}" target="_blank">{downloadIcon}</a>';
tActionZoom = '<button type="button" class="kv-file-zoom {zoomClass}" ' +
'title="{zoomTitle}">{zoomIcon}</button>';
tActionDrag = '<span class="file-drag-handle {dragClass}" title="{dragTitle}">{dragIcon}</span>';
tIndicator = '<div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>';
tTagBef = '<div class="file-preview-frame {frameClass}" id="{previewId}" data-fileindex="{fileindex}"' +
' data-fileid="{fileid}" data-template="{template}"';
tTagBef1 = tTagBef + '><div class="kv-file-content">\n';
tTagBef2 = tTagBef + ' title="{caption}"><div class="kv-file-content">\n';
tTagAft = '</div>{footer}\n</div>\n';
tGeneric = '{content}\n';
tStyle = ' {style}';
tHtml = '<div class="kv-preview-data file-preview-html" title="{caption}"' + tStyle + '>{data}</div>\n';
tImage = '<img src="{data}" class="file-preview-image kv-preview-data" title="{title}" ' +
'alt="{alt}"' + tStyle + '>\n';
tText = '<textarea class="kv-preview-data file-preview-text" title="{caption}" readonly' + tStyle + '>' +
'{data}</textarea>\n';
tOffice = '<iframe class="kv-preview-data file-preview-office" ' +
'src="https://view.officeapps.live.com/op/embed.aspx?src={data}"' + tStyle + '></iframe>';
tGdocs = '<iframe class="kv-preview-data file-preview-gdocs" ' +
'src="https://docs.google.com/gview?url={data}&embedded=true"' + tStyle + '></iframe>';
tVideo = '<video class="kv-preview-data file-preview-video" controls' + tStyle + '>\n' +
'<source src="{data}" type="{type}">\n' + $h.DEFAULT_PREVIEW + '\n</video>\n';
tAudio = '<!--suppress ALL --><audio class="kv-preview-data file-preview-audio" controls' + tStyle + '>\n<source src="{data}" ' +
'type="{type}">\n' + $h.DEFAULT_PREVIEW + '\n</audio>\n';
tFlash = '<embed class="kv-preview-data file-preview-flash" src="{data}" type="application/x-shockwave-flash"' + tStyle + '>\n';
tPdf = '<embed class="kv-preview-data file-preview-pdf" src="{data}" type="application/pdf"' + tStyle + '>\n';
tObject = '<object class="kv-preview-data file-preview-object file-object {typeCss}" ' +
'data="{data}" type="{type}"' + tStyle + '>\n' + '<param name="movie" value="{caption}" />\n' +
$h.OBJECT_PARAMS + ' ' + $h.DEFAULT_PREVIEW + '\n</object>\n';
tOther = '<div class="kv-preview-data file-preview-other-frame"' + tStyle + '>\n' + $h.DEFAULT_PREVIEW + '\n</div>\n';
tZoomCache = '<div class="kv-zoom-cache" style="display:none">{zoomContent}</div>';
vDefaultDim = {width: '100%', height: '100%', 'min-height': '480px'};
if (self._isPdfRendered()) {
tPdf = self.pdfRendererTemplate.replace('{renderer}', self._encodeURI(self.pdfRendererUrl));
}
self.defaults = {
layoutTemplates: {
main1: tMain1,
main2: tMain2,
preview: tPreview,
close: tClose,
fileIcon: tFileIcon,
caption: tCaption,
modalMain: tModalMain,
modal: tModal,
progress: tProgress,
size: tSize,
footer: tFooter,
indicator: tIndicator,
actions: tActions,
actionDelete: tActionDelete,
actionUpload: tActionUpload,
actionDownload: tActionDownload,
actionZoom: tActionZoom,
actionDrag: tActionDrag,
btnDefault: tBtnDefault,
btnLink: tBtnLink,
btnBrowse: tBtnBrowse,
zoomCache: tZoomCache
},
previewMarkupTags: {
tagBefore1: tTagBef1,
tagBefore2: tTagBef2,
tagAfter: tTagAft
},
previewContentTemplates: {
generic: tGeneric,
html: tHtml,
image: tImage,
text: tText,
office: tOffice,
gdocs: tGdocs,
video: tVideo,
audio: tAudio,
flash: tFlash,
object: tObject,
pdf: tPdf,
other: tOther
},
allowedPreviewTypes: ['image', 'html', 'text', 'video', 'audio', 'flash', 'pdf', 'object'],
previewTemplates: {},
previewSettings: {
image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'},
html: {width: '213px', height: '160px'},
text: {width: '213px', height: '160px'},
office: {width: '213px', height: '160px'},
gdocs: {width: '213px', height: '160px'},
video: {width: '213px', height: '160px'},
audio: {width: '100%', height: '30px'},
flash: {width: '213px', height: '160px'},
object: {width: '213px', height: '160px'},
pdf: {width: '100%', height: '160px'},
other: {width: '213px', height: '160px'}
},
previewSettingsSmall: {
image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'},
html: {width: '100%', height: '160px'},
text: {width: '100%', height: '160px'},
office: {width: '100%', height: '160px'},
gdocs: {width: '100%', height: '160px'},
video: {width: '100%', height: 'auto'},
audio: {width: '100%', height: '30px'},
flash: {width: '100%', height: 'auto'},
object: {width: '100%', height: 'auto'},
pdf: {width: '100%', height: '160px'},
other: {width: '100%', height: '160px'}
},
previewZoomSettings: {
image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'},
html: vDefaultDim,
text: vDefaultDim,
office: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'},
gdocs: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'},
video: {width: 'auto', height: '100%', 'max-width': '100%'},
audio: {width: '100%', height: '30px'},
flash: {width: 'auto', height: '480px'},
object: {width: 'auto', height: '100%', 'max-width': '100%', 'min-height': '480px'},
pdf: vDefaultDim,
other: {width: 'auto', height: '100%', 'min-height': '480px'}
},
mimeTypeAliases: {
'video/quicktime': 'video/mp4'
},
fileTypeSettings: {
image: function (vType, vName) {
return ($h.compare(vType, 'image.*') && !$h.compare(vType, /(tiff?|wmf)$/i) ||
$h.compare(vName, /\.(gif|png|jpe?g)$/i));
},
html: function (vType, vName) {
return $h.compare(vType, 'text/html') || $h.compare(vName, /\.(htm|html)$/i);
},
office: function (vType, vName) {
return $h.compare(vType, /(word|excel|powerpoint|office)$/i) ||
$h.compare(vName, /\.(docx?|xlsx?|pptx?|pps|potx?)$/i);
},
gdocs: function (vType, vName) {
return $h.compare(vType, /(word|excel|powerpoint|office|iwork-pages|tiff?)$/i) ||
$h.compare(vName,
/\.(docx?|xlsx?|pptx?|pps|potx?|rtf|ods|odt|pages|ai|dxf|ttf|tiff?|wmf|e?ps)$/i);
},
text: function (vType, vName) {
return $h.compare(vType, 'text.*') || $h.compare(vName, /\.(xml|javascript)$/i) ||
$h.compare(vName, /\.(txt|md|csv|nfo|ini|json|php|js|css)$/i);
},
video: function (vType, vName) {
return $h.compare(vType, 'video.*') && ($h.compare(vType, /(ogg|mp4|mp?g|mov|webm|3gp)$/i) ||
$h.compare(vName, /\.(og?|mp4|webm|mp?g|mov|3gp)$/i));
},
audio: function (vType, vName) {
return $h.compare(vType, 'audio.*') && ($h.compare(vName, /(ogg|mp3|mp?g|wav)$/i) ||
$h.compare(vName, /\.(og?|mp3|mp?g|wav)$/i));
},
flash: function (vType, vName) {
return $h.compare(vType, 'application/x-shockwave-flash', true) || $h.compare(vName,
/\.(swf)$/i);
},
pdf: function (vType, vName) {
return $h.compare(vType, 'application/pdf', true) || $h.compare(vName, /\.(pdf)$/i);
},
object: function () {
return true;
},
other: function () {
return true;
}
},
fileActionSettings: {
showRemove: true,
showUpload: true,
showDownload: true,
showZoom: true,
showDrag: true,
removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
removeClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
removeErrorClass: 'btn btn-sm btn-kv btn-danger',
removeTitle: 'Remove file',
uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
uploadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
uploadTitle: 'Upload file',
uploadRetryIcon: '<i class="glyphicon glyphicon-repeat"></i>',
uploadRetryTitle: 'Retry upload',
downloadIcon: '<i class="glyphicon glyphicon-download"></i>',
downloadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
downloadTitle: 'Download file',
zoomIcon: '<i class="glyphicon glyphicon-zoom-in"></i>',
zoomClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
zoomTitle: 'View Details',
dragIcon: '<i class="glyphicon glyphicon-move"></i>',
dragClass: 'text-info',
dragTitle: 'Move / Rearrange',
dragSettings: {},
indicatorNew: '<i class="glyphicon glyphicon-plus-sign text-warning"></i>',
indicatorSuccess: '<i class="glyphicon glyphicon-ok-sign text-success"></i>',
indicatorError: '<i class="glyphicon glyphicon-exclamation-sign text-danger"></i>',
indicatorLoading: '<i class="glyphicon glyphicon-hourglass text-muted"></i>',
indicatorNewTitle: 'Not uploaded yet',
indicatorSuccessTitle: 'Uploaded',
indicatorErrorTitle: 'Upload Error',
indicatorLoadingTitle: 'Uploading ...'
}
};
$.each(self.defaults, function (key, setting) {
if (key === 'allowedPreviewTypes') {
if (self.allowedPreviewTypes === undefined) {
self.allowedPreviewTypes = setting;
}
return;
}
self[key] = $.extend(true, {}, setting, self[key]);
});
self._initPreviewTemplates();
},
_initPreviewTemplates: function () {
var self = this, tags = self.previewMarkupTags, tagBef, tagAft = tags.tagAfter;
$.each(self.previewContentTemplates, function (key, value) {
if ($h.isEmpty(self.previewTemplates[key])) {
tagBef = tags.tagBefore2;
if (key === 'generic' || key === 'image' || key === 'html' || key === 'text') {
tagBef = tags.tagBefore1;
}
if (self._isPdfRendered() && key === 'pdf') {
tagBef = tagBef.replace('kv-file-content', 'kv-file-content kv-pdf-rendered');
}
self.previewTemplates[key] = tagBef + value + tagAft;
}
});
},
_initPreviewCache: function () {
var self = this;
self.previewCache = {
data: {},
init: function () {
var content = self.initialPreview;
if (content.length > 0 && !$h.isArray(content)) {
content = content.split(self.initialPreviewDelimiter);
}
self.previewCache.data = {
content: content,
config: self.initialPreviewConfig,
tags: self.initialPreviewThumbTags
};
},
count: function () {
return !!self.previewCache.data && !!self.previewCache.data.content ?
self.previewCache.data.content.length : 0;
},
get: function (i, isDisabled) {
var ind = 'init_' + i, data = self.previewCache.data, config = data.config[i],
content = data.content[i], previewId = self.previewInitId + '-' + ind, out, $tmp, cat, ftr,
fname, ftype, frameClass, asData = $h.ifSet('previewAsData', config, self.initialPreviewAsData),
a = config ? {title: config.title || null, alt: config.alt || null} : {title: null, alt: null},
parseTemplate = function (cat, dat, fn, ft, id, ftr, ind, fc, t) {
fc = ' file-preview-initial ' + $h.SORT_CSS + (fc ? ' ' + fc : '');
return self._generatePreviewTemplate(cat, dat, fn, ft, id, false, null, fc, ftr, ind, t, a);
};
if (!content) {
return '';
}
isDisabled = isDisabled === undefined ? true : isDisabled;
cat = $h.ifSet('type', config, self.initialPreviewFileType || 'generic');
fname = $h.ifSet('filename', config, $h.ifSet('caption', config));
ftype = $h.ifSet('filetype', config, cat);
ftr = self.previewCache.footer(i, isDisabled, (config && config.size || null));
frameClass = $h.ifSet('frameClass', config);
if (asData) {
out = parseTemplate(cat, content, fname, ftype, previewId, ftr, ind, frameClass);
} else {
out = parseTemplate('generic', content, fname, ftype, previewId, ftr, ind, frameClass, cat)
.setTokens({'content': data.content[i]});
}
if (data.tags.length && data.tags[i]) {
out = $h.replaceTags(out, data.tags[i]);
}
/** @namespace config.frameAttr */
if (!$h.isEmpty(config) && !$h.isEmpty(config.frameAttr)) {
$tmp = $(document.createElement('div')).html(out);
$tmp.find('.file-preview-initial').attr(config.frameAttr);
out = $tmp.html();
$tmp.remove();
}
return out;
},
add: function (content, config, tags, append) {
var data = self.previewCache.data, index;
if (!$h.isArray(content)) {
content = content.split(self.initialPreviewDelimiter);
}
if (append) {
index = data.content.push(content) - 1;
data.config[index] = config;
data.tags[index] = tags;
} else {
index = content.length - 1;
data.content = content;
data.config = config;
data.tags = tags;
}
self.previewCache.data = data;
return index;
},
set: function (content, config, tags, append) {
var data = self.previewCache.data, i, chk;
if (!content || !content.length) {
return;
}
if (!$h.isArray(content)) {
content = content.split(self.initialPreviewDelimiter);
}
chk = content.filter(function (n) {
return n !== null;
});
if (!chk.length) {
return;
}
if (data.content === undefined) {
data.content = [];
}
if (data.config === undefined) {
data.config = [];
}
if (data.tags === undefined) {
data.tags = [];
}
if (append) {
for (i = 0; i < content.length; i++) {
if (content[i]) {
data.content.push(content[i]);
}
}
for (i = 0; i < config.length; i++) {
if (config[i]) {
data.config.push(config[i]);
}
}
for (i = 0; i < tags.length; i++) {
if (tags[i]) {
data.tags.push(tags[i]);
}
}
} else {
data.content = content;
data.config = config;
data.tags = tags;
}
self.previewCache.data = data;
},
unset: function (index) {
var chk = self.previewCache.count(), rev = self.reversePreviewOrder;
if (!chk) {
return;
}
if (chk === 1) {
self.previewCache.data.content = [];
self.previewCache.data.config = [];
self.previewCache.data.tags = [];
self.initialPreview = [];
self.initialPreviewConfig = [];
self.initialPreviewThumbTags = [];
return;
}
self.previewCache.data.content = $h.spliceArray(self.previewCache.data.content, index, rev);
self.previewCache.data.config = $h.spliceArray(self.previewCache.data.config, index, rev);
self.previewCache.data.tags = $h.spliceArray(self.previewCache.data.tags, index, rev);
},
out: function () {
var html = '', caption, len = self.previewCache.count(), i, content;
if (len === 0) {
return {content: '', caption: ''};
}
for (i = 0; i < len; i++) {
content = self.previewCache.get(i);
html = self.reversePreviewOrder ? (content + html) : (html + content);
}
caption = self._getMsgSelected(len);
return {content: html, caption: caption};
},
footer: function (i, isDisabled, size) {
var data = self.previewCache.data || {};
if ($h.isEmpty(data.content)) {
return '';
}
if ($h.isEmpty(data.config) || $h.isEmpty(data.config[i])) {
data.config[i] = {};
}
isDisabled = isDisabled === undefined ? true : isDisabled;
var config = data.config[i], caption = $h.ifSet('caption', config), a,
width = $h.ifSet('width', config, 'auto'), url = $h.ifSet('url', config, false),
key = $h.ifSet('key', config, null), fs = self.fileActionSettings,
initPreviewShowDel = self.initialPreviewShowDelete || false,
dUrl = config.downloadUrl || self.initialPreviewDownloadUrl || '',
dFil = config.filename || config.caption || '',
initPreviewShowDwl = !!(dUrl),
sDel = $h.ifSet('showRemove', config, $h.ifSet('showRemove', fs, initPreviewShowDel)),
sDwl = $h.ifSet('showDownload', config, $h.ifSet('showDownload', fs, initPreviewShowDwl)),
sZm = $h.ifSet('showZoom', config, $h.ifSet('showZoom', fs, true)),
sDrg = $h.ifSet('showDrag', config, $h.ifSet('showDrag', fs, true)),
dis = (url === false) && isDisabled;
sDwl = sDwl && config.downloadUrl !== false && !!dUrl;
a = self._renderFileActions(false, sDwl, sDel, sZm, sDrg, dis, url, key, true, dUrl, dFil);
return self._getLayoutTemplate('footer').setTokens({
'progress': self._renderThumbProgress(),
'actions': a,
'caption': caption,
'size': self._getSize(size),
'width': width,
'indicator': ''
});
}
};
self.previewCache.init();
},
_isPdfRendered: function () {
var self = this, useLib = self.usePdfRenderer,
flag = typeof useLib === 'function' ? useLib() : !!useLib;
return flag && self.pdfRendererUrl;
},
_handler: function ($el, event, callback) {
var self = this, ns = self.namespace, ev = event.split(' ').join(ns + ' ') + ns;
if (!$el || !$el.length) {
return;
}
$el.off(ev).on(ev, callback);
},
_encodeURI: function (vUrl) {
var self = this;
return self.encodeUrl ? encodeURI(vUrl) : vUrl;
},
_log: function (msg) {
var self = this, id = self.$element.attr('id');
if (id) {
msg = '"' + id + '": ' + msg;
}
msg = 'bootstrap-fileinput: ' + msg;
if (typeof window.console.log !== 'undefined') {
window.console.log(msg);
} else {
window.alert(msg);
}
},
_validate: function () {
var self = this, status = self.$element.attr('type') === 'file';
if (!status) {
self._log('The input "type" must be set to "file" for initializing the "bootstrap-fileinput" plugin.');
}
return status;
},
_errorsExist: function () {
var self = this, $err, $errList = self.$errorContainer.find('li');
if ($errList.length) {
return true;
}
$err = $(document.createElement('div')).html(self.$errorContainer.html());
$err.find('.kv-error-close').remove();
$err.find('ul').remove();
return !!$.trim($err.text()).length;
},
_errorHandler: function (evt, caption) {
var self = this, err = evt.target.error, showError = function (msg) {
self._showError(msg.replace('{name}', caption));
};
/** @namespace err.NOT_FOUND_ERR */
/** @namespace err.SECURITY_ERR */
/** @namespace err.NOT_READABLE_ERR */
if (err.code === err.NOT_FOUND_ERR) {
showError(self.msgFileNotFound);
} else {
if (err.code === err.SECURITY_ERR) {
showError(self.msgFileSecured);
} else {
if (err.code === err.NOT_READABLE_ERR) {
showError(self.msgFileNotReadable);
} else {
if (err.code === err.ABORT_ERR) {
showError(self.msgFilePreviewAborted);
} else {
showError(self.msgFilePreviewError);
}
}
}
}
},
_addError: function (msg) {
var self = this, $error = self.$errorContainer;
if (msg && $error.length) {
$error.html(self.errorCloseButton + msg);
self._handler($error.find('.kv-error-close'), 'click', function () {
setTimeout(function () {
if (self.showPreview && !self.getFrames().length) {
self.clear();
}
$error.fadeOut('slow');
}, 10);
});
}
},
_setValidationError: function (css) {
var self = this;
css = (css ? css + ' ' : '') + 'has-error';
self.$container.removeClass(css).addClass('has-error');
$h.addCss(self.$captionContainer, 'is-invalid');
},
_resetErrors: function (fade) {
var self = this, $error = self.$errorContainer;
self.isError = false;
self.$container.removeClass('has-error');
self.$captionContainer.removeClass('is-invalid');
$error.html('');
if (fade) {
$error.fadeOut('slow');
} else {
$error.hide();
}
},
_showFolderError: function (folders) {
var self = this, $error = self.$errorContainer, msg;
if (!folders) {
return;
}
if (!self.isAjaxUpload) {
self._clearFileInput();
}
msg = self.msgFoldersNotAllowed.replace('{n}', folders);
self._addError(msg);
self._setValidationError();
$error.fadeIn(800);
self._raise('filefoldererror', [folders, msg]);
},
_showUploadError: function (msg, params, event) {
var self = this, $error = self.$errorContainer, ev = event || 'fileuploaderror', e = params && params.id ?
'<li data-thumb-id="' + params.id + '">' + msg + '</li>' : '<li>' + msg + '</li>';
if ($error.find('ul').length === 0) {
self._addError('<ul>' + e + '</ul>');
} else {
$error.find('ul').append(e);
}
$error.fadeIn(800);
self._raise(ev, [params, msg]);
self._setValidationError('file-input-new');
return true;
},
_showError: function (msg, params, event) {
var self = this, $error = self.$errorContainer, ev = event || 'fileerror';
params = params || {};
params.reader = self.reader;
self._addError(msg);
$error.fadeIn(800);
self._raise(ev, [params, msg]);
if (!self.isAjaxUpload) {
self._clearFileInput();
}
self._setValidationError('file-input-new');
self.$btnUpload.attr('disabled', true);
return true;
},
_noFilesError: function (params) {
var self = this, label = self.minFileCount > 1 ? self.filePlural : self.fileSingle,
msg = self.msgFilesTooLess.replace('{n}', self.minFileCount).replace('{files}', label),
$error = self.$errorContainer;
self._addError(msg);
self.isError = true;
self._updateFileDetails(0);
$error.fadeIn(800);
self._raise('fileerror', [params, msg]);
self._clearFileInput();
self._setValidationError();
},
_parseError: function (operation, jqXHR, errorThrown, fileName) {
/** @namespace jqXHR.responseJSON */
var self = this, errMsg = $.trim(errorThrown + ''), textPre,
text = jqXHR.responseJSON !== undefined && jqXHR.responseJSON.error !== undefined ?
jqXHR.responseJSON.error : jqXHR.responseText;
if (self.cancelling && self.msgUploadAborted) {
errMsg = self.msgUploadAborted;
}
if (self.showAjaxErrorDetails && text) {
text = $.trim(text.replace(/\n\s*\n/g, '\n'));
textPre = text.length ? '<pre>' + text + '</pre>' : '';
errMsg += errMsg ? textPre : text;
}
if (!errMsg) {
errMsg = self.msgAjaxError.replace('{operation}', operation);
}
self.cancelling = false;
return fileName ? '<b>' + fileName + ': </b>' + errMsg : errMsg;
},
_parseFileType: function (type, name) {
var self = this, isValid, vType, cat, i, types = self.allowedPreviewTypes || [];
if (type === 'application/text-plain') {
return 'text';
}
for (i = 0; i < types.length; i++) {
cat = types[i];
isValid = self.fileTypeSettings[cat];
vType = isValid(type, name) ? cat : '';
if (!$h.isEmpty(vType)) {
return vType;
}
}
return 'other';
},
_getPreviewIcon: function (fname) {
var self = this, ext, out = null;
if (fname && fname.indexOf('.') > -1) {
ext = fname.split('.').pop();
if (self.previewFileIconSettings) {
out = self.previewFileIconSettings[ext] || self.previewFileIconSettings[ext.toLowerCase()] || null;
}
if (self.previewFileExtSettings) {
$.each(self.previewFileExtSettings, function (key, func) {
if (self.previewFileIconSettings[key] && func(ext)) {
out = self.previewFileIconSettings[key];
//noinspection UnnecessaryReturnStatementJS
return;
}
});
}
}
return out;
},
_parseFilePreviewIcon: function (content, fname) {
var self = this, icn = self._getPreviewIcon(fname) || self.previewFileIcon, out = content;
if (out.indexOf('{previewFileIcon}') > -1) {
out = out.setTokens({'previewFileIconClass': self.previewFileIconClass, 'previewFileIcon': icn});
}
return out;
},
_raise: function (event, params) {
var self = this, e = $.Event(event);
if (params !== undefined) {
self.$element.trigger(e, params);
} else {
self.$element.trigger(e);
}
if (e.isDefaultPrevented() || e.result === false) {
return false;
}
switch (event) {
// ignore these events
case 'filebatchuploadcomplete':
case 'filebatchuploadsuccess':
case 'fileuploaded':
case 'fileclear':
case 'filecleared':
case 'filereset':
case 'fileerror':
case 'filefoldererror':
case 'fileuploaderror':
case 'filebatchuploaderror':
case 'filedeleteerror':
case 'filecustomerror':
case 'filesuccessremove':
break;
// receive data response via `filecustomerror` event`
default:
if (!self.ajaxAborted) {
self.ajaxAborted = e.result;
}
break;
}
return true;
},
_listenFullScreen: function (isFullScreen) {
var self = this, $modal = self.$modal, $btnFull, $btnBord;
if (!$modal || !$modal.length) {
return;
}
$btnFull = $modal && $modal.find('.btn-fullscreen');
$btnBord = $modal && $modal.find('.btn-borderless');
if (!$btnFull.length || !$btnBord.length) {
return;
}
$btnFull.removeClass('active').attr('aria-pressed', 'false');
$btnBord.removeClass('active').attr('aria-pressed', 'false');
if (isFullScreen) {
$btnFull.addClass('active').attr('aria-pressed', 'true');
} else {
$btnBord.addClass('active').attr('aria-pressed', 'true');
}
if ($modal.hasClass('file-zoom-fullscreen')) {
self._maximizeZoomDialog();
} else {
if (isFullScreen) {
self._maximizeZoomDialog();
} else {
$btnBord.removeClass('active').attr('aria-pressed', 'false');
}
}
},
_listen: function () {
var self = this, $el = self.$element, $form = self.$form, $cont = self.$container, fullScreenEvents;
self._handler($el, 'click', function (e) {
if ($el.hasClass('file-no-browse')) {
if ($el.data('zoneClicked')) {
$el.data('zoneClicked', false);
} else {
e.preventDefault();
}
}
});
self._handler($el, 'change', $.proxy(self._change, self));
if (self.showBrowse) {
self._handler(self.$btnFile, 'click', $.proxy(self._browse, self));
}
self._handler($cont.find('.fileinput-remove:not([disabled])'), 'click', $.proxy(self.clear, self));
self._handler($cont.find('.fileinput-cancel'), 'click', $.proxy(self.cancel, self));
self._initDragDrop();
self._handler($form, 'reset', $.proxy(self.clear, self));
if (!self.isAjaxUpload) {
self._handler($form, 'submit', $.proxy(self._submitForm, self));
}
self._handler(self.$container.find('.fileinput-upload'), 'click', $.proxy(self._uploadClick, self));
self._handler($(window), 'resize', function () {
self._listenFullScreen(screen.width === window.innerWidth && screen.height === window.innerHeight);
});
fullScreenEvents = 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange';
self._handler($(document), fullScreenEvents, function () {
self._listenFullScreen($h.checkFullScreen());
});
self._autoFitContent();
self._initClickable();
self._refreshPreview();
},
_autoFitContent: function () {
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
self = this, config = width < 400 ? (self.previewSettingsSmall || self.defaults.previewSettingsSmall) :
(self.previewSettings || self.defaults.previewSettings), sel;
$.each(config, function (cat, settings) {
sel = '.file-preview-frame .file-preview-' + cat;
self.$preview.find(sel + '.kv-preview-data,' + sel + ' .kv-preview-data').css(settings);
});
},
_scanDroppedItems: function (item, files, path) {
path = path || '';
var self = this, i, dirReader, readDir, errorHandler = function (e) {
self._log('Error scanning dropped files!');
self._log(e);
};
if (item.isFile) {
item.file(function (file) {
files.push(file);
}, errorHandler);
} else {
if (item.isDirectory) {
dirReader = item.createReader();
readDir = function () {
dirReader.readEntries(function (entries) {
if (entries && entries.length > 0) {
for (i = 0; i < entries.length; i++) {
self._scanDroppedItems(entries[i], files, path + item.name + '/');
}
// recursively call readDir() again, since browser can only handle first 100 entries.
readDir();
}
return null;
}, errorHandler);
};
readDir();
}
}
},
_initDragDrop: function () {
var self = this, $zone = self.$dropZone;
if (self.dropZoneEnabled && self.showPreview) {
self._handler($zone, 'dragenter dragover', $.proxy(self._zoneDragEnter, self));
self._handler($zone, 'dragleave', $.proxy(self._zoneDragLeave, self));
self._handler($zone, 'drop', $.proxy(self._zoneDrop, self));
self._handler($(document), 'dragenter dragover drop', self._zoneDragDropInit);
}
},
_zoneDragDropInit: function (e) {
e.stopPropagation();
e.preventDefault();
},
_zoneDragEnter: function (e) {
var self = this, dataTransfer = e.originalEvent.dataTransfer,
hasFiles = $.inArray('Files', dataTransfer.types) > -1;
self._zoneDragDropInit(e);
if (self.isDisabled || !hasFiles) {
e.originalEvent.dataTransfer.effectAllowed = 'none';
e.originalEvent.dataTransfer.dropEffect = 'none';
return;
}
if (self._raise('fileDragEnter', {'sourceEvent': e, 'files': dataTransfer.types.Files})) {
$h.addCss(self.$dropZone, 'file-highlighted');
}
},
_zoneDragLeave: function (e) {
var self = this;
self._zoneDragDropInit(e);
if (self.isDisabled) {
return;
}
if (self._raise('fileDragLeave', {'sourceEvent': e})) {
self.$dropZone.removeClass('file-highlighted');
}
},
_zoneDrop: function (e) {
/** @namespace e.originalEvent.dataTransfer */
var self = this, i, $el = self.$element, dataTransfer = e.originalEvent.dataTransfer,
files = dataTransfer.files, items = dataTransfer.items, folders = $h.getDragDropFolders(items),
processFiles = function () {
if (!self.isAjaxUpload) {
self.changeTriggered = true;
$el.get(0).files = files;
setTimeout(function () {
self.changeTriggered = false;
$el.trigger('change' + self.namespace);
}, 10);
} else {
self._change(e, files);
}
self.$dropZone.removeClass('file-highlighted');
};
e.preventDefault();
if (self.isDisabled || $h.isEmpty(files)) {
return;
}
if (!self._raise('fileDragDrop', {'sourceEvent': e, 'files': files})) {
return;
}
if (folders > 0) {
if (!self.isAjaxUpload) {
self._showFolderError(folders);
return;
}
files = [];
for (i = 0; i < items.length; i++) {
var item = items[i].webkitGetAsEntry();
if (item) {
self._scanDroppedItems(item, files);
}
}
setTimeout(function () {
processFiles();
}, 500);
} else {
processFiles();
}
},
_uploadClick: function (e) {
var self = this, $btn = self.$container.find('.fileinput-upload'), $form,
isEnabled = !$btn.hasClass('disabled') && $h.isEmpty($btn.attr('disabled'));
if (e && e.isDefaultPrevented()) {
return;
}
if (!self.isAjaxUpload) {
if (isEnabled && $btn.attr('type') !== 'submit') {
$form = $btn.closest('form');
// downgrade to normal form submit if possible
if ($form.length) {
$form.trigger('submit');
}
e.preventDefault();
}
return;
}
e.preventDefault();
if (isEnabled) {
self.upload();
}
},
_submitForm: function () {
var self = this;
return self._isFileSelectionValid() && !self._abort({});
},
_clearPreview: function () {
var self = this, $p = self.$preview,
$thumbs = self.showUploadedThumbs ? self.getFrames(':not(.file-preview-success)') : self.getFrames();
$thumbs.each(function () {
var $thumb = $(this);
$thumb.remove();
$h.cleanZoomCache($p.find('#zoom-' + $thumb.attr('id')));
});
if (!self.getFrames().length || !self.showPreview) {
self._resetUpload();
}
self._validateDefaultPreview();
},
_initSortable: function () {
var self = this, $el = self.$preview, settings, selector = '.' + $h.SORT_CSS,
rev = self.reversePreviewOrder;
if (!window.KvSortable || $el.find(selector).length === 0) {
return;
}
//noinspection JSUnusedGlobalSymbols
settings = {
handle: '.drag-handle-init',
dataIdAttr: 'data-preview-id',
scroll: false,
draggable: selector,
onSort: function (e) {
var oldIndex = e.oldIndex, newIndex = e.newIndex, i = 0;
self.initialPreview = $h.moveArray(self.initialPreview, oldIndex, newIndex, rev);
self.initialPreviewConfig = $h.moveArray(self.initialPreviewConfig, oldIndex, newIndex, rev);
self.previewCache.init();
self.getFrames('.file-preview-initial').each(function () {
$(this).attr('data-fileindex', 'init_' + i);
i++;
});
self._raise('filesorted', {
previewId: $(e.item).attr('id'),
'oldIndex': oldIndex,
'newIndex': newIndex,
stack: self.initialPreviewConfig
});
}
};
if ($el.data('kvsortable')) {
$el.kvsortable('destroy');
}
$.extend(true, settings, self.fileActionSettings.dragSettings);
$el.kvsortable(settings);
},
_setPreviewContent: function (content) {
var self = this;
self.$preview.html(content);
self._autoFitContent();
},
_initPreview: function (isInit) {
var self = this, cap = self.initialCaption || '', out;
if (!self.previewCache.count()) {
self._clearPreview();
if (isInit) {
self._setCaption(cap);
} else {
self._initCaption();
}
return;
}
out = self.previewCache.out();
cap = isInit && self.initialCaption ? self.initialCaption : out.caption;
self._setPreviewContent(out.content);
self._setInitThumbAttr();
self._setCaption(cap);
self._initSortable();
if (!$h.isEmpty(out.content)) {
self.$container.removeClass('file-input-new');
}
},
_getZoomButton: function (type) {
var self = this, label = self.previewZoomButtonIcons[type], css = self.previewZoomButtonClasses[type],
title = ' title="' + (self.previewZoomButtonTitles[type] || '') + '" ',
params = title + (type === 'close' ? ' data-dismiss="modal" aria-hidden="true"' : '');
if (type === 'fullscreen' || type === 'borderless' || type === 'toggleheader') {
params += ' data-toggle="button" aria-pressed="false" autocomplete="off"';
}
return '<button type="button" class="' + css + ' btn-' + type + '"' + params + '>' + label + '</button>';
},
_getModalContent: function () {
var self = this;
return self._getLayoutTemplate('modal').setTokens({
'rtl': self.rtl ? ' kv-rtl' : '',
'zoomFrameClass': self.frameClass,
'heading': self.msgZoomModalHeading,
'prev': self._getZoomButton('prev'),
'next': self._getZoomButton('next'),
'toggleheader': self._getZoomButton('toggleheader'),
'fullscreen': self._getZoomButton('fullscreen'),
'borderless': self._getZoomButton('borderless'),
'close': self._getZoomButton('close')
});
},
_listenModalEvent: function (event) {
var self = this, $modal = self.$modal, getParams = function (e) {
return {
sourceEvent: e,
previewId: $modal.data('previewId'),
modal: $modal
};
};
$modal.on(event + '.bs.modal', function (e) {
var $btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless');
self._raise('filezoom' + event, getParams(e));
if (event === 'shown') {
$btnBord.removeClass('active').attr('aria-pressed', 'false');
$btnFull.removeClass('active').attr('aria-pressed', 'false');
if ($modal.hasClass('file-zoom-fullscreen')) {
self._maximizeZoomDialog();
if ($h.checkFullScreen()) {
$btnFull.addClass('active').attr('aria-pressed', 'true');
} else {
$btnBord.addClass('active').attr('aria-pressed', 'true');
}
}
}
});
},
_initZoom: function () {
var self = this, $dialog, modalMain = self._getLayoutTemplate('modalMain'), modalId = '#' + $h.MODAL_ID;
if (!self.showPreview) {
return;
}
self.$modal = $(modalId);
if (!self.$modal || !self.$modal.length) {
$dialog = $(document.createElement('div')).html(modalMain).insertAfter(self.$container);
self.$modal = $(modalId).insertBefore($dialog);
$dialog.remove();
}
$h.initModal(self.$modal);
self.$modal.html(self._getModalContent());
$.each($h.MODAL_EVENTS, function (key, event) {
self._listenModalEvent(event);
});
},
_initZoomButtons: function () {
var self = this, previewId = self.$modal.data('previewId') || '', $first, $last,
thumbs = self.getFrames().toArray(), len = thumbs.length, $prev = self.$modal.find('.btn-prev'),
$next = self.$modal.find('.btn-next');
if (thumbs.length < 2) {
$prev.hide();
$next.hide();
return;
} else {
$prev.show();
$next.show();
}
if (!len) {
return;
}
$first = $(thumbs[0]);
$last = $(thumbs[len - 1]);
$prev.removeAttr('disabled');
$next.removeAttr('disabled');
if ($first.length && $first.attr('id') === previewId) {
$prev.attr('disabled', true);
}
if ($last.length && $last.attr('id') === previewId) {
$next.attr('disabled', true);
}
},
_maximizeZoomDialog: function () {
var self = this, $modal = self.$modal, $head = $modal.find('.modal-header:visible'),
$foot = $modal.find('.modal-footer:visible'), $body = $modal.find('.modal-body'),
h = $(window).height(), diff = 0;
$modal.addClass('file-zoom-fullscreen');
if ($head && $head.length) {
h -= $head.outerHeight(true);
}
if ($foot && $foot.length) {
h -= $foot.outerHeight(true);
}
if ($body && $body.length) {
diff = $body.outerHeight(true) - $body.height();
h -= diff;
}
$modal.find('.kv-zoom-body').height(h);
},
_resizeZoomDialog: function (fullScreen) {
var self = this, $modal = self.$modal, $btnFull = $modal.find('.btn-fullscreen'),
$btnBord = $modal.find('.btn-borderless');
if ($modal.hasClass('file-zoom-fullscreen')) {
$h.toggleFullScreen(false);
if (!fullScreen) {
if (!$btnFull.hasClass('active')) {
$modal.removeClass('file-zoom-fullscreen');
self.$modal.find('.kv-zoom-body').css('height', self.zoomModalHeight);
} else {
$btnFull.removeClass('active').attr('aria-pressed', 'false');
}
} else {
if (!$btnFull.hasClass('active')) {
$modal.removeClass('file-zoom-fullscreen');
self._resizeZoomDialog(true);
if ($btnBord.hasClass('active')) {
$btnBord.removeClass('active').attr('aria-pressed', 'false');
}
}
}
} else {
if (!fullScreen) {
self._maximizeZoomDialog();
return;
}
$h.toggleFullScreen(true);
}
$modal.focus();
},
_setZoomContent: function ($frame, animate) {
var self = this, $content, tmplt, body, title, $body, $dataEl, config, previewId = $frame.attr('id'),
$zoomPreview = self.$preview.find('#zoom-' + previewId), $modal = self.$modal, $tmp,
$btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless'), cap, size,
$btnTogh = $modal.find('.btn-toggleheader');
tmplt = $zoomPreview.attr('data-template') || 'generic';
$content = $zoomPreview.find('.kv-file-content');
body = $content.length ? $content.html() : '';
cap = $frame.data('caption') || '';
size = $frame.data('size') || '';
title = cap + ' ' + size;
$modal.find('.kv-zoom-title').attr('title', $('<div/>').html(title).text()).html(title);
$body = $modal.find('.kv-zoom-body');
$modal.removeClass('kv-single-content');
if (animate) {
$tmp = $body.addClass('file-thumb-loading').clone().insertAfter($body);
$body.html(body).hide();
$tmp.fadeOut('fast', function () {
$body.fadeIn('fast', function () {
$body.removeClass('file-thumb-loading');
});
$tmp.remove();
});
} else {
$body.html(body);
}
config = self.previewZoomSettings[tmplt];
if (config) {
$dataEl = $body.find('.kv-preview-data');
$h.addCss($dataEl, 'file-zoom-detail');
$.each(config, function (key, value) {
$dataEl.css(key, value);
if (($dataEl.attr('width') && key === 'width') || ($dataEl.attr('height') && key === 'height')) {
$dataEl.removeAttr(key);
}
});
}
$modal.data('previewId', previewId);
self._handler($modal.find('.btn-prev'), 'click', function () {
self._zoomSlideShow('prev', previewId);
});
self._handler($modal.find('.btn-next'), 'click', function () {
self._zoomSlideShow('next', previewId);
});
self._handler($btnFull, 'click', function () {
self._resizeZoomDialog(true);
});
self._handler($btnBord, 'click', function () {
self._resizeZoomDialog(false);
});
self._handler($btnTogh, 'click', function () {
var $header = $modal.find('.modal-header'), $floatBar = $modal.find('.modal-body .floating-buttons'),
ht, $actions = $header.find('.kv-zoom-actions'), resize = function (height) {
var $body = self.$modal.find('.kv-zoom-body'), h = self.zoomModalHeight;
if ($modal.hasClass('file-zoom-fullscreen')) {
h = $body.outerHeight(true);
if (!height) {
h = h - $header.outerHeight(true);
}
}
$body.css('height', height ? h + height : h);
};
if ($header.is(':visible')) {
ht = $header.outerHeight(true);
$header.slideUp('slow', function () {
$actions.find('.btn').appendTo($floatBar);
resize(ht);
});
} else {
$floatBar.find('.btn').appendTo($actions);
$header.slideDown('slow', function () {
resize();
});
}
$modal.focus();
});
self._handler($modal, 'keydown', function (e) {
var key = e.which || e.keyCode, $prev = $(this).find('.btn-prev'), $next = $(this).find('.btn-next'),
vId = $(this).data('previewId'), vPrevKey = self.rtl ? 39 : 37, vNextKey = self.rtl ? 37 : 39;
if (key === vPrevKey && $prev.length && !$prev.attr('disabled')) {
self._zoomSlideShow('prev', vId);
}
if (key === vNextKey && $next.length && !$next.attr('disabled')) {
self._zoomSlideShow('next', vId);
}
});
},
_zoomPreview: function ($btn) {
var self = this, $frame, $modal = self.$modal;
if (!$btn.length) {
throw 'Cannot zoom to detailed preview!';
}
$h.initModal($modal);
$modal.html(self._getModalContent());
$frame = $btn.closest($h.FRAMES);
self._setZoomContent($frame);
$modal.modal('show');
self._initZoomButtons();
},
_zoomSlideShow: function (dir, previewId) {
var self = this, $btn = self.$modal.find('.kv-zoom-actions .btn-' + dir), $targFrame, i,
thumbs = self.getFrames().toArray(), len = thumbs.length, out;
if ($btn.attr('disabled')) {
return;
}
for (i = 0; i < len; i++) {
if ($(thumbs[i]).attr('id') === previewId) {
out = dir === 'prev' ? i - 1 : i + 1;
break;
}
}
if (out < 0 || out >= len || !thumbs[out]) {
return;
}
$targFrame = $(thumbs[out]);
if ($targFrame.length) {
self._setZoomContent($targFrame, true);
}
self._initZoomButtons();
self._raise('filezoom' + dir, {'previewId': previewId, modal: self.$modal});
},
_initZoomButton: function () {
var self = this;
self.$preview.find('.kv-file-zoom').each(function () {
var $el = $(this);
self._handler($el, 'click', function () {
self._zoomPreview($el);
});
});
},
_inputFileCount: function () {
return this.$element.get(0).files.length;
},
_refreshPreview: function () {
var self = this, files;
if ((!self._inputFileCount() && !self.isAjaxUpload) || !self.showPreview || !self.isPreviewable) {
return;
}
if (self.isAjaxUpload) {
files = self.getFileStack();
self.filestack = [];
if (files.length) {
self._clearFileInput();
} else {
files = self.$element.get(0).files;
}
} else {
files = self.$element.get(0).files;
}
if (files && files.length) {
self.readFiles(files);
self._setFileDropZoneTitle();
}
},
_clearObjects: function ($el) {
$el.find('video audio').each(function () {
this.pause();
$(this).remove();
});
$el.find('img object div').each(function () {
$(this).remove();
});
},
_clearFileInput: function () {
var self = this, $el = self.$element, $srcFrm, $tmpFrm, $tmpEl;
if (!self._inputFileCount()) {
return;
}
$srcFrm = $el.closest('form');
$tmpFrm = $(document.createElement('form'));
$tmpEl = $(document.createElement('div'));
$el.before($tmpEl);
if ($srcFrm.length) {
$srcFrm.after($tmpFrm);
} else {
$tmpEl.after($tmpFrm);
}
$tmpFrm.append($el).trigger('reset');
$tmpEl.before($el).remove();
$tmpFrm.remove();
},
_resetUpload: function () {
var self = this;
self.uploadCache = {content: [], config: [], tags: [], append: true};
self.uploadCount = 0;
self.uploadStatus = {};
self.uploadLog = [];
self.uploadAsyncCount = 0;
self.loadedImages = [];
self.totalImagesCount = 0;
self.$btnUpload.removeAttr('disabled');
self._setProgress(0);
self.$progress.hide();
self._resetErrors(false);
self.ajaxAborted = false;
self.ajaxRequests = [];
self._resetCanvas();
self.cacheInitialPreview = {};
if (self.overwriteInitial) {
self.initialPreview = [];
self.initialPreviewConfig = [];
self.initialPreviewThumbTags = [];
self.previewCache.data = {
content: [],
config: [],
tags: []
};
}
},
_resetCanvas: function () {
var self = this;
if (self.canvas && self.imageCanvasContext) {
self.imageCanvasContext.clearRect(0, 0, self.canvas.width, self.canvas.height);
}
},
_hasInitialPreview: function () {
var self = this;
return !self.overwriteInitial && self.previewCache.count();
},
_resetPreview: function () {
var self = this, out, cap;
if (self.previewCache.count()) {
out = self.previewCache.out();
self._setPreviewContent(out.content);
self._setInitThumbAttr();
cap = self.initialCaption ? self.initialCaption : out.caption;
self._setCaption(cap);
} else {
self._clearPreview();
self._initCaption();
}
if (self.showPreview) {
self._initZoom();
self._initSortable();
}
},
_clearDefaultPreview: function () {
var self = this;
self.$preview.find('.file-default-preview').remove();
},
_validateDefaultPreview: function () {
var self = this;
if (!self.showPreview || $h.isEmpty(self.defaultPreviewContent)) {
return;
}
self._setPreviewContent('<div class="file-default-preview">' + self.defaultPreviewContent + '</div>');
self.$container.removeClass('file-input-new');
self._initClickable();
},
_resetPreviewThumbs: function (isAjax) {
var self = this, out;
if (isAjax) {
self._clearPreview();
self.clearStack();
return;
}
if (self._hasInitialPreview()) {
out = self.previewCache.out();
self._setPreviewContent(out.content);
self._setInitThumbAttr();
self._setCaption(out.caption);
self._initPreviewActions();
} else {
self._clearPreview();
}
},
_getLayoutTemplate: function (t) {
var self = this, template = self.layoutTemplates[t];
if ($h.isEmpty(self.customLayoutTags)) {
return template;
}
return $h.replaceTags(template, self.customLayoutTags);
},
_getPreviewTemplate: function (t) {
var self = this, template = self.previewTemplates[t];
if ($h.isEmpty(self.customPreviewTags)) {
return template;
}
return $h.replaceTags(template, self.customPreviewTags);
},
_getOutData: function (jqXHR, responseData, filesData) {
var self = this;
jqXHR = jqXHR || {};
responseData = responseData || {};
filesData = filesData || self.filestack.slice(0) || {};
return {
form: self.formdata,
files: filesData,
filenames: self.filenames,
filescount: self.getFilesCount(),
extra: self._getExtraData(),
response: responseData,
reader: self.reader,
jqXHR: jqXHR
};
},
_getMsgSelected: function (n) {
var self = this, strFiles = n === 1 ? self.fileSingle : self.filePlural;
return n > 0 ? self.msgSelected.replace('{n}', n).replace('{files}', strFiles) : self.msgNoFilesSelected;
},
_getFrame: function (id) {
var self = this, $frame = $('#' + id);
if (!$frame.length) {
self._log('Invalid thumb frame with id: "' + id + '".');
return null;
}
return $frame;
},
_getThumbs: function (css) {
css = css || '';
return this.getFrames(':not(.file-preview-initial)' + css);
},
_getExtraData: function (previewId, index) {
var self = this, data = self.uploadExtraData;
if (typeof self.uploadExtraData === 'function') {
data = self.uploadExtraData(previewId, index);
}
return data;
},
_initXhr: function (xhrobj, previewId, fileCount) {
var self = this;
if (xhrobj.upload) {
xhrobj.upload.addEventListener('progress', function (event) {
var pct = 0, total = event.total, position = event.loaded || event.position;
/** @namespace event.lengthComputable */
if (event.lengthComputable) {
pct = Math.floor(position / total * 100);
}
if (previewId) {
self._setAsyncUploadStatus(previewId, pct, fileCount);
} else {
self._setProgress(pct);
}
}, false);
}
return xhrobj;
},
_initAjaxSettings: function () {
var self = this;
self._ajaxSettings = $.extend(true, {}, self.ajaxSettings);
self._ajaxDeleteSettings = $.extend(true, {}, self.ajaxDeleteSettings);
},
_mergeAjaxCallback: function (funcName, srcFunc, type) {
var self = this, settings = self._ajaxSettings, flag = self.mergeAjaxCallbacks, targFunc;
if (type === 'delete') {
settings = self._ajaxDeleteSettings;
flag = self.mergeAjaxDeleteCallbacks;
}
targFunc = settings[funcName];
if (flag && typeof targFunc === 'function') {
if (flag === 'before') {
settings[funcName] = function () {
targFunc.apply(this, arguments);
srcFunc.apply(this, arguments);
};
} else {
settings[funcName] = function () {
srcFunc.apply(this, arguments);
targFunc.apply(this, arguments);
};
}
} else {
settings[funcName] = srcFunc;
}
},
_ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, previewId, index) {
var self = this, settings, vUrl;
if (!self._raise('filepreajax', [previewId, index])) {
return;
}
self._uploadExtra(previewId, index);
self._initAjaxSettings();
self._mergeAjaxCallback('beforeSend', fnBefore);
self._mergeAjaxCallback('success', fnSuccess);
self._mergeAjaxCallback('complete', fnComplete);
self._mergeAjaxCallback('error', fnError);
vUrl = index && self.uploadUrlThumb ? self.uploadUrlThumb : self.uploadUrl;
settings = $.extend(true, {}, {
xhr: function () {
var xhrobj = $.ajaxSettings.xhr();
return self._initXhr(xhrobj, previewId, self.getFileStack().length);
},
url: self._encodeURI(vUrl),
type: 'POST',
dataType: 'json',
data: self.formdata,
cache: false,
processData: false,
contentType: false
}, self._ajaxSettings);
self.ajaxRequests.push($.ajax(settings));
},
_mergeArray: function (prop, content) {
var self = this, arr1 = $h.cleanArray(self[prop]), arr2 = $h.cleanArray(content);
self[prop] = arr1.concat(arr2);
},
_initUploadSuccess: function (out, $thumb, allFiles) {
var self = this, append, data, index, $div, $newCache, content, config, tags, i;
if (!self.showPreview || typeof out !== 'object' || $.isEmptyObject(out)) {
return;
}
if (out.initialPreview !== undefined && out.initialPreview.length > 0) {
self.hasInitData = true;
content = out.initialPreview || [];
config = out.initialPreviewConfig || [];
tags = out.initialPreviewThumbTags || [];
append = out.append === undefined || out.append;
if (content.length > 0 && !$h.isArray(content)) {
content = content.split(self.initialPreviewDelimiter);
}
self._mergeArray('initialPreview', content);
self._mergeArray('initialPreviewConfig', config);
self._mergeArray('initialPreviewThumbTags', tags);
if ($thumb !== undefined) {
if (!allFiles) {
index = self.previewCache.add(content, config[0], tags[0], append);
data = self.previewCache.get(index, false);
$div = $(document.createElement('div')).html(data).hide().insertAfter($thumb);
$newCache = $div.find('.kv-zoom-cache');
if ($newCache && $newCache.length) {
$newCache.insertAfter($thumb);
}
$thumb.fadeOut('slow', function () {
var $newThumb = $div.find('.file-preview-frame');
if ($newThumb && $newThumb.length) {
$newThumb.insertBefore($thumb).fadeIn('slow').css('display:inline-block');
}
self._initPreviewActions();
self._clearFileInput();
$h.cleanZoomCache(self.$preview.find('#zoom-' + $thumb.attr('id')));
$thumb.remove();
$div.remove();
self._initSortable();
});
} else {
i = $thumb.attr('data-fileindex');
self.uploadCache.content[i] = content[0];
self.uploadCache.config[i] = config[0] || [];
self.uploadCache.tags[i] = tags[0] || [];
self.uploadCache.append = append;
}
} else {
self.previewCache.set(content, config, tags, append);
self._initPreview();
self._initPreviewActions();
}
}
},
_initSuccessThumbs: function () {
var self = this;
if (!self.showPreview) {
return;
}
self._getThumbs($h.FRAMES + '.file-preview-success').each(function () {
var $thumb = $(this), $preview = self.$preview, $remove = $thumb.find('.kv-file-remove');
$remove.removeAttr('disabled');
self._handler($remove, 'click', function () {
var id = $thumb.attr('id'),
out = self._raise('filesuccessremove', [id, $thumb.attr('data-fileindex')]);
$h.cleanMemory($thumb);
if (out === false) {
return;
}
$thumb.fadeOut('slow', function () {
$h.cleanZoomCache($preview.find('#zoom-' + id));
$thumb.remove();
if (!self.getFrames().length) {
self.reset();
}
});
});
});
},
_checkAsyncComplete: function () {
var self = this, previewId, i;
for (i = 0; i < self.filestack.length; i++) {
if (self.filestack[i]) {
previewId = self.previewInitId + '-' + i;
if ($.inArray(previewId, self.uploadLog) === -1) {
return false;
}
}
}
return (self.uploadAsyncCount === self.uploadLog.length);
},
_uploadExtra: function (previewId, index) {
var self = this, data = self._getExtraData(previewId, index);
if (data.length === 0) {
return;
}
$.each(data, function (key, value) {
self.formdata.append(key, value);
});
},
_uploadSingle: function (i, isBatch) {
var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
previewId = self.previewInitId + '-' + i, $thumb, chkComplete, $btnUpload, $btnDelete,
hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData), uploadFailed,
$prog = $('#' + previewId).find('.file-thumb-progress'), fnBefore, fnSuccess, fnComplete, fnError,
updateUploadLog, params = {id: previewId, index: i};
self.formdata = formdata;
if (self.showPreview) {
$thumb = $('#' + previewId + ':not(.file-preview-initial)');
$btnUpload = $thumb.find('.kv-file-upload');
$btnDelete = $thumb.find('.kv-file-remove');
$prog.show();
}
if (total === 0 || !hasPostData || ($btnUpload && $btnUpload.hasClass('disabled')) || self._abort(params)) {
return;
}
updateUploadLog = function (i, previewId) {
if (!uploadFailed) {
self.updateStack(i, undefined);
}
self.uploadLog.push(previewId);
if (self._checkAsyncComplete()) {
self.fileBatchCompleted = true;
}
};
chkComplete = function () {
var u = self.uploadCache, $initThumbs, i, j, len = 0, data = self.cacheInitialPreview;
if (!self.fileBatchCompleted) {
return;
}
if (data && data.content) {
len = data.content.length;
}
setTimeout(function () {
var triggerReset = self.getFileStack(true).length === 0;
if (self.showPreview) {
self.previewCache.set(u.content, u.config, u.tags, u.append);
if (len) {
for (i = 0; i < u.content.length; i++) {
j = i + len;
data.content[j] = u.content[i];
//noinspection JSUnresolvedVariable
if (data.config.length) {
data.config[j] = u.config[i];
}
if (data.tags.length) {
data.tags[j] = u.tags[i];
}
}
self.initialPreview = $h.cleanArray(data.content);
self.initialPreviewConfig = $h.cleanArray(data.config);
self.initialPreviewThumbTags = $h.cleanArray(data.tags);
} else {
self.initialPreview = u.content;
self.initialPreviewConfig = u.config;
self.initialPreviewThumbTags = u.tags;
}
self.cacheInitialPreview = {};
if (self.hasInitData) {
self._initPreview();
self._initPreviewActions();
}
}
self.unlock(triggerReset);
if (triggerReset) {
self._clearFileInput();
}
$initThumbs = self.$preview.find('.file-preview-initial');
if (self.uploadAsync && $initThumbs.length) {
$h.addCss($initThumbs, $h.SORT_CSS);
self._initSortable();
}
self._raise('filebatchuploadcomplete', [self.filestack, self._getExtraData()]);
self.uploadCount = 0;
self.uploadStatus = {};
self.uploadLog = [];
self._setProgress(101);
self.ajaxAborted = false;
}, 100);
};
fnBefore = function (jqXHR) {
outData = self._getOutData(jqXHR);
self.fileBatchCompleted = false;
if (!isBatch) {
self.ajaxAborted = false;
}
if (self.showPreview) {
if (!$thumb.hasClass('file-preview-success')) {
self._setThumbStatus($thumb, 'Loading');
$h.addCss($thumb, 'file-uploading');
}
$btnUpload.attr('disabled', true);
$btnDelete.attr('disabled', true);
}
if (!isBatch) {
self.lock();
}
self._raise('filepreupload', [outData, previewId, i]);
$.extend(true, params, outData);
if (self._abort(params)) {
jqXHR.abort();
if (!isBatch) {
self._setThumbStatus($thumb, 'New');
$thumb.removeClass('file-uploading');
$btnUpload.removeAttr('disabled');
$btnDelete.removeAttr('disabled');
self.unlock();
}
self._setProgressCancelled();
}
};
fnSuccess = function (data, textStatus, jqXHR) {
var pid = self.showPreview && $thumb.attr('id') ? $thumb.attr('id') : previewId;
outData = self._getOutData(jqXHR, data);
$.extend(true, params, outData);
setTimeout(function () {
if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
if (self.showPreview) {
self._setThumbStatus($thumb, 'Success');
$btnUpload.hide();
self._initUploadSuccess(data, $thumb, isBatch);
self._setProgress(101, $prog);
}
self._raise('fileuploaded', [outData, pid, i]);
if (!isBatch) {
self.updateStack(i, undefined);
} else {
updateUploadLog(i, pid);
}
} else {
uploadFailed = true;
self._showUploadError(data.error, params);
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$btnUpload.hide();
}
if (isBatch) {
updateUploadLog(i, pid);
}
self._setProgress(101, $('#' + pid).find('.file-thumb-progress'), self.msgUploadError);
}
}, 100);
};
fnComplete = function () {
setTimeout(function () {
if (self.showPreview) {
$btnUpload.removeAttr('disabled');
$btnDelete.removeAttr('disabled');
$thumb.removeClass('file-uploading');
}
if (!isBatch) {
self.unlock(false);
self._clearFileInput();
} else {
chkComplete();
}
self._initSuccessThumbs();
}, 100);
};
fnError = function (jqXHR, textStatus, errorThrown) {
var op = self.ajaxOperations.uploadThumb,
errMsg = self._parseError(op, jqXHR, errorThrown,
(isBatch && self.filestack[i].name ? self.filestack[i].name : null));
uploadFailed = true;
setTimeout(function () {
if (isBatch) {
updateUploadLog(i, previewId);
}
self.uploadStatus[previewId] = 100;
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$btnUpload.hide();
}
$.extend(true, params, self._getOutData(jqXHR));
self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op));
self._setProgress(101, $('#' + previewId).find('.file-thumb-progress'), self.msgUploadError);
self._showUploadError(errMsg, params);
}, 100);
};
formdata.append(self.uploadFileAttr, self.filestack[i], self.filenames[i]);
formdata.append('file_id', i);
self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, previewId, i);
},
_uploadBatch: function () {
var self = this, files = self.filestack, total = files.length, params = {}, fnBefore, fnSuccess, fnError,
fnComplete, hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData),
setAllUploaded;
self.formdata = new FormData();
if (total === 0 || !hasPostData || self._abort(params)) {
return;
}
setAllUploaded = function () {
$.each(files, function (key) {
self.updateStack(key, undefined);
});
self._clearFileInput();
};
fnBefore = function (jqXHR) {
self.lock();
var outData = self._getOutData(jqXHR);
self.ajaxAborted = false;
if (self.showPreview) {
self._getThumbs().each(function () {
var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'),
$btnDelete = $thumb.find('.kv-file-remove');
if (!$thumb.hasClass('file-preview-success')) {
self._setThumbStatus($thumb, 'Loading');
$h.addCss($thumb, 'file-uploading');
}
$btnUpload.attr('disabled', true);
$btnDelete.attr('disabled', true);
});
}
self._raise('filebatchpreupload', [outData]);
if (self._abort(outData)) {
jqXHR.abort();
self._getThumbs().each(function () {
var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'),
$btnDelete = $thumb.find('.kv-file-remove');
if ($thumb.hasClass('file-preview-loading')) {
self._setThumbStatus($thumb, 'New');
$thumb.removeClass('file-uploading');
}
$btnUpload.removeAttr('disabled');
$btnDelete.removeAttr('disabled');
});
self._setProgressCancelled();
}
};
fnSuccess = function (data, textStatus, jqXHR) {
/** @namespace data.errorkeys */
var outData = self._getOutData(jqXHR, data), key = 0,
$thumbs = self._getThumbs(':not(.file-preview-success)'),
keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys;
if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
self._raise('filebatchuploadsuccess', [outData]);
setAllUploaded();
if (self.showPreview) {
$thumbs.each(function () {
var $thumb = $(this);
self._setThumbStatus($thumb, 'Success');
$thumb.removeClass('file-uploading');
$thumb.find('.kv-file-upload').hide().removeAttr('disabled');
});
self._initUploadSuccess(data);
} else {
self.reset();
}
self._setProgress(101);
} else {
if (self.showPreview) {
$thumbs.each(function () {
var $thumb = $(this), i = $thumb.attr('data-fileindex');
$thumb.removeClass('file-uploading');
$thumb.find('.kv-file-upload').removeAttr('disabled');
$thumb.find('.kv-file-remove').removeAttr('disabled');
if (keys.length === 0 || $.inArray(key, keys) !== -1) {
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$thumb.find('.kv-file-upload').hide();
self.updateStack(i, undefined);
}
} else {
$thumb.find('.kv-file-upload').hide();
self._setThumbStatus($thumb, 'Success');
self.updateStack(i, undefined);
}
if (!$thumb.hasClass('file-preview-error') || self.retryErrorUploads) {
key++;
}
});
self._initUploadSuccess(data);
}
self._showUploadError(data.error, outData, 'filebatchuploaderror');
self._setProgress(101, self.$progress, self.msgUploadError);
}
};
fnComplete = function () {
self.unlock();
self._initSuccessThumbs();
self._clearFileInput();
self._raise('filebatchuploadcomplete', [self.filestack, self._getExtraData()]);
};
fnError = function (jqXHR, textStatus, errorThrown) {
var outData = self._getOutData(jqXHR), op = self.ajaxOperations.uploadBatch,
errMsg = self._parseError(op, jqXHR, errorThrown);
self._showUploadError(errMsg, outData, 'filebatchuploaderror');
self.uploadFileCount = total - 1;
if (!self.showPreview) {
return;
}
self._getThumbs().each(function () {
var $thumb = $(this), key = $thumb.attr('data-fileindex');
$thumb.removeClass('file-uploading');
if (self.filestack[key] !== undefined) {
self._setPreviewError($thumb);
}
});
self._getThumbs().removeClass('file-uploading');
self._getThumbs(' .kv-file-upload').removeAttr('disabled');
self._getThumbs(' .kv-file-delete').removeAttr('disabled');
self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op));
};
$.each(files, function (key, data) {
if (!$h.isEmpty(files[key])) {
self.formdata.append(self.uploadFileAttr, data, self.filenames[key]);
}
});
self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError);
},
_uploadExtraOnly: function () {
var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError;
self.formdata = new FormData();
if (self._abort(params)) {
return;
}
fnBefore = function (jqXHR) {
self.lock();
var outData = self._getOutData(jqXHR);
self._raise('filebatchpreupload', [outData]);
self._setProgress(50);
params.data = outData;
params.xhr = jqXHR;
if (self._abort(params)) {
jqXHR.abort();
self._setProgressCancelled();
}
};
fnSuccess = function (data, textStatus, jqXHR) {
var outData = self._getOutData(jqXHR, data);
if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
self._raise('filebatchuploadsuccess', [outData]);
self._clearFileInput();
self._initUploadSuccess(data);
self._setProgress(101);
} else {
self._showUploadError(data.error, outData, 'filebatchuploaderror');
}
};
fnComplete = function () {
self.unlock();
self._clearFileInput();
self._raise('filebatchuploadcomplete', [self.filestack, self._getExtraData()]);
};
fnError = function (jqXHR, textStatus, errorThrown) {
var outData = self._getOutData(jqXHR), op = self.ajaxOperations.uploadExtra,
errMsg = self._parseError(op, jqXHR, errorThrown);
params.data = outData;
self._showUploadError(errMsg, outData, 'filebatchuploaderror');
self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op));
};
self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError);
},
_deleteFileIndex: function ($frame) {
var self = this, ind = $frame.attr('data-fileindex'), rev = self.reversePreviewOrder;
if (ind.substring(0, 5) === 'init_') {
ind = parseInt(ind.replace('init_', ''));
self.initialPreview = $h.spliceArray(self.initialPreview, ind, rev);
self.initialPreviewConfig = $h.spliceArray(self.initialPreviewConfig, ind, rev);
self.initialPreviewThumbTags = $h.spliceArray(self.initialPreviewThumbTags, ind, rev);
self.getFrames().each(function () {
var $nFrame = $(this), nInd = $nFrame.attr('data-fileindex');
if (nInd.substring(0, 5) === 'init_') {
nInd = parseInt(nInd.replace('init_', ''));
if (nInd > ind) {
nInd--;
$nFrame.attr('data-fileindex', 'init_' + nInd);
}
}
});
if (self.uploadAsync) {
self.cacheInitialPreview = self.getPreview();
}
}
},
_initFileActions: function () {
var self = this, $preview = self.$preview;
if (!self.showPreview) {
return;
}
self._initZoomButton();
self.getFrames(' .kv-file-remove').each(function () {
var $el = $(this), $frame = $el.closest($h.FRAMES), hasError, id = $frame.attr('id'),
ind = $frame.attr('data-fileindex'), n, cap, status;
self._handler($el, 'click', function () {
status = self._raise('filepreremove', [id, ind]);
if (status === false || !self._validateMinCount()) {
return false;
}
hasError = $frame.hasClass('file-preview-error');
$h.cleanMemory($frame);
$frame.fadeOut('slow', function () {
$h.cleanZoomCache($preview.find('#zoom-' + id));
self.updateStack(ind, undefined);
self._clearObjects($frame);
$frame.remove();
if (id && hasError) {
self.$errorContainer.find('li[data-thumb-id="' + id + '"]').fadeOut('fast', function () {
$(this).remove();
if (!self._errorsExist()) {
self._resetErrors();
}
});
}
self._clearFileInput();
var filestack = self.getFileStack(true), chk = self.previewCache.count(),
len = filestack.length, hasThumb = self.showPreview && self.getFrames().length;
if (len === 0 && chk === 0 && !hasThumb) {
self.reset();
} else {
n = chk + len;
cap = n > 1 ? self._getMsgSelected(n) : (filestack[0] ? self._getFileNames()[0] : '');
self._setCaption(cap);
}
self._raise('fileremoved', [id, ind]);
});
});
});
self.getFrames(' .kv-file-upload').each(function () {
var $el = $(this);
self._handler($el, 'click', function () {
var $frame = $el.closest($h.FRAMES), ind = $frame.attr('data-fileindex');
self.$progress.hide();
if ($frame.hasClass('file-preview-error') && !self.retryErrorUploads) {
return;
}
self._uploadSingle(ind, false);
});
});
},
_initPreviewActions: function () {
var self = this, $preview = self.$preview, deleteExtraData = self.deleteExtraData || {},
btnRemove = $h.FRAMES + ' .kv-file-remove', settings = self.fileActionSettings,
origClass = settings.removeClass, errClass = settings.removeErrorClass,
resetProgress = function () {
var hasFiles = self.isAjaxUpload ? self.previewCache.count() : self._inputFileCount();
if (!$preview.find($h.FRAMES).length && !hasFiles) {
self._setCaption('');
self.reset();
self.initialCaption = '';
}
};
self._initZoomButton();
$preview.find(btnRemove).each(function () {
var $el = $(this), vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'),
fnBefore, fnSuccess, fnError;
if ($h.isEmpty(vUrl) || vKey === undefined) {
return;
}
var $frame = $el.closest($h.FRAMES), cache = self.previewCache.data,
settings, params, index = $frame.attr('data-fileindex'), config, extraData;
index = parseInt(index.replace('init_', ''));
config = $h.isEmpty(cache.config) && $h.isEmpty(cache.config[index]) ? null : cache.config[index];
extraData = $h.isEmpty(config) || $h.isEmpty(config.extra) ? deleteExtraData : config.extra;
if (typeof extraData === 'function') {
extraData = extraData();
}
params = {id: $el.attr('id'), key: vKey, extra: extraData};
fnBefore = function (jqXHR) {
self.ajaxAborted = false;
self._raise('filepredelete', [vKey, jqXHR, extraData]);
if (self._abort()) {
jqXHR.abort();
} else {
$el.removeClass(errClass);
$h.addCss($frame, 'file-uploading');
$h.addCss($el, 'disabled ' + origClass);
}
};
fnSuccess = function (data, textStatus, jqXHR) {
var n, cap;
if (!$h.isEmpty(data) && !$h.isEmpty(data.error)) {
params.jqXHR = jqXHR;
params.response = data;
self._showError(data.error, params, 'filedeleteerror');
$frame.removeClass('file-uploading');
$el.removeClass('disabled ' + origClass).addClass(errClass);
resetProgress();
return;
}
$frame.removeClass('file-uploading').addClass('file-deleted');
$frame.fadeOut('slow', function () {
index = parseInt(($frame.attr('data-fileindex')).replace('init_', ''));
self.previewCache.unset(index);
self._deleteFileIndex($frame);
n = self.previewCache.count();
cap = n > 0 ? self._getMsgSelected(n) : '';
self._setCaption(cap);
self._raise('filedeleted', [vKey, jqXHR, extraData]);
$h.cleanZoomCache($preview.find('#zoom-' + $frame.attr('id')));
self._clearObjects($frame);
$frame.remove();
resetProgress();
});
};
fnError = function (jqXHR, textStatus, errorThrown) {
var op = self.ajaxOperations.deleteThumb, errMsg = self._parseError(op, jqXHR, errorThrown);
params.jqXHR = jqXHR;
params.response = {};
self._showError(errMsg, params, 'filedeleteerror');
$frame.removeClass('file-uploading');
$el.removeClass('disabled ' + origClass).addClass(errClass);
resetProgress();
};
self._initAjaxSettings();
self._mergeAjaxCallback('beforeSend', fnBefore, 'delete');
self._mergeAjaxCallback('success', fnSuccess, 'delete');
self._mergeAjaxCallback('error', fnError, 'delete');
settings = $.extend(true, {}, {
url: self._encodeURI(vUrl),
type: 'POST',
dataType: 'json',
data: $.extend(true, {}, {key: vKey}, extraData)
}, self._ajaxDeleteSettings);
self._handler($el, 'click', function () {
if (!self._validateMinCount()) {
return false;
}
self.ajaxAborted = false;
self._raise('filebeforedelete', [vKey, extraData]);
//noinspection JSUnresolvedVariable,JSHint
if (self.ajaxAborted instanceof Promise) {
self.ajaxAborted.then(function (result) {
if (!result) {
$.ajax(settings);
}
});
} else {
if (!self.ajaxAborted) {
$.ajax(settings);
}
}
});
});
},
_hideFileIcon: function () {
var self = this;
if (self.overwriteInitial) {
self.$captionContainer.removeClass('icon-visible');
}
},
_showFileIcon: function () {
var self = this;
$h.addCss(self.$captionContainer, 'icon-visible');
},
_getSize: function (bytes) {
var self = this, size = parseFloat(bytes), i, func = self.fileSizeGetter, sizes, out;
if (!$.isNumeric(bytes) || !$.isNumeric(size)) {
return '';
}
if (typeof func === 'function') {
out = func(size);
} else {
if (size === 0) {
out = '0.00 B';
} else {
i = Math.floor(Math.log(size) / Math.log(1024));
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
out = (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i];
}
}
return self._getLayoutTemplate('size').replace('{sizeText}', out);
},
_getFileType: function (ftype) {
var self = this;
return self.mimeTypeAliases[ftype] || ftype;
},
_generatePreviewTemplate: function (
cat,
data,
fname,
ftype,
previewId,
isError,
size,
frameClass,
foot,
ind,
templ,
attrs
) {
var self = this, caption = self.slug(fname), prevContent, zoomContent = '', styleAttribs = '',
screenW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
config = screenW < 400 ? (self.previewSettingsSmall[cat] || self.defaults.previewSettingsSmall[cat]) :
(self.previewSettings[cat] || self.defaults.previewSettings[cat]), title = caption, alt = caption,
footer = foot || self._renderFileFooter(caption, size, 'auto', isError),
hasIconSetting = self._getPreviewIcon(fname), typeCss = 'type-default',
forcePrevIcon = hasIconSetting && self.preferIconicPreview,
forceZoomIcon = hasIconSetting && self.preferIconicZoomPreview, getContent;
if (config) {
$.each(config, function (key, val) {
styleAttribs += key + ':' + val + ';';
});
}
getContent = function (c, d, zoom, frameCss) {
var id = zoom ? 'zoom-' + previewId : previewId, tmplt = self._getPreviewTemplate(c),
css = (frameClass || '') + ' ' + frameCss;
if (self.frameClass) {
css = self.frameClass + ' ' + css;
}
if (zoom) {
css = css.replace(' ' + $h.SORT_CSS, '');
}
tmplt = self._parseFilePreviewIcon(tmplt, fname);
if (c === 'text') {
d = $h.htmlEncode(d);
}
if (cat === 'object' && !ftype) {
$.each(self.defaults.fileTypeSettings, function (key, func) {
if (key === 'object' || key === 'other') {
return;
}
if (func(fname, ftype)) {
typeCss = 'type-' + key;
}
});
}
if (!$h.isEmpty(attrs)) {
if (attrs.title !== undefined && attrs.title !== null) {
title = attrs.title;
}
if (attrs.alt !== undefined && attrs.alt !== null) {
title = attrs.alt;
}
}
return tmplt.setTokens({
'previewId': id,
'caption': caption,
'title': title,
'alt': alt,
'frameClass': css,
'type': self._getFileType(ftype),
'fileindex': ind,
'fileid': self._getFileIds()[ind] || '',
'typeCss': typeCss,
'footer': footer,
'data': d,
'template': templ || cat,
'style': styleAttribs ? 'style="' + styleAttribs + '"' : ''
});
};
ind = ind || previewId.slice(previewId.lastIndexOf('-') + 1);
if (self.fileActionSettings.showZoom) {
zoomContent = getContent((forceZoomIcon ? 'other' : cat), data, true, 'kv-zoom-thumb');
}
zoomContent = '\n' + self._getLayoutTemplate('zoomCache').replace('{zoomContent}', zoomContent);
prevContent = getContent((forcePrevIcon ? 'other' : cat), data, false, 'kv-preview-thumb');
return prevContent + zoomContent;
},
_addToPreview: function ($preview, content) {
var self = this;
return self.reversePreviewOrder ? $preview.prepend(content) : $preview.append(content);
},
_previewDefault: function (file, previewId, isDisabled) {
var self = this, $preview = self.$preview;
if (!self.showPreview) {
return;
}
var fname = $h.getFileName(file), ftype = file ? file.type : '', content, size = file.size || 0,
caption = self.slug(fname), isError = isDisabled === true && !self.isAjaxUpload,
data = $h.createObjectURL(file);
self._clearDefaultPreview();
content = self._generatePreviewTemplate('other', data, fname, ftype, previewId, isError, size);
self._addToPreview($preview, content);
self._setThumbAttr(previewId, caption, size);
if (isDisabled === true && self.isAjaxUpload) {
self._setThumbStatus($('#' + previewId), 'Error');
}
},
_previewFile: function (i, file, theFile, previewId, data, fileInfo) {
if (!this.showPreview) {
return;
}
var self = this, fname = $h.getFileName(file), ftype = fileInfo.type, caption = fileInfo.name,
cat = self._parseFileType(ftype, fname), types = self.allowedPreviewTypes, content,
mimes = self.allowedPreviewMimeTypes, $preview = self.$preview, fsize = file.size || 0,
chkTypes = types && types.indexOf(cat) >= 0, chkMimes = mimes && mimes.indexOf(ftype) !== -1,
iData = (cat === 'text' || cat === 'html' || cat === 'image') ? theFile.target.result : data;
/** @namespace window.DOMPurify */
if (cat === 'html' && self.purifyHtml && window.DOMPurify) {
iData = window.DOMPurify.sanitize(iData);
}
if (chkTypes || chkMimes) {
content = self._generatePreviewTemplate(cat, iData, fname, ftype, previewId, false, fsize);
self._clearDefaultPreview();
self._addToPreview($preview, content);
var $img = $preview.find('#' + previewId + ' img');
self._validateImageOrientation($img, file, previewId, caption, ftype, fsize, iData);
} else {
self._previewDefault(file, previewId);
}
self._setThumbAttr(previewId, caption, fsize);
self._initSortable();
},
_setThumbAttr: function (id, caption, size) {
var self = this, $frame = $('#' + id);
if ($frame.length) {
size = size && size > 0 ? self._getSize(size) : '';
$frame.data({'caption': caption, 'size': size});
}
},
_setInitThumbAttr: function () {
var self = this, data = self.previewCache.data, len = self.previewCache.count(), config,
caption, size, previewId;
if (len === 0) {
return;
}
for (var i = 0; i < len; i++) {
config = data.config[i];
previewId = self.previewInitId + '-' + 'init_' + i;
caption = $h.ifSet('caption', config, $h.ifSet('filename', config));
size = $h.ifSet('size', config);
self._setThumbAttr(previewId, caption, size);
}
},
_slugDefault: function (text) {
// noinspection RegExpRedundantEscape
return $h.isEmpty(text) ? '' : String(text).replace(/[\[\]\/\{}:;#%=\(\)\*\+\?\\\^\$\|<>&"']/g, '_');
},
_updateFileDetails: function (numFiles) {
var self = this, $el = self.$element, fileStack = self.getFileStack(),
name = ($h.isIE(9) && $h.findFileName($el.val())) ||
($el[0].files[0] && $el[0].files[0].name) || (fileStack.length && fileStack[0].name) || '',
label = self.slug(name), n = self.isAjaxUpload ? fileStack.length : numFiles,
nFiles = self.previewCache.count() + n, log = n === 1 ? label : self._getMsgSelected(nFiles);
if (self.isError) {
self.$previewContainer.removeClass('file-thumb-loading');
self.$previewStatus.html('');
self.$captionContainer.removeClass('icon-visible');
} else {
self._showFileIcon();
}
self._setCaption(log, self.isError);
self.$container.removeClass('file-input-new file-input-ajax-new');
if (arguments.length === 1) {
self._raise('fileselect', [numFiles, label]);
}
if (self.previewCache.count()) {
self._initPreviewActions();
}
},
_setThumbStatus: function ($thumb, status) {
var self = this;
if (!self.showPreview) {
return;
}
var icon = 'indicator' + status, msg = icon + 'Title',
css = 'file-preview-' + status.toLowerCase(),
$indicator = $thumb.find('.file-upload-indicator'),
config = self.fileActionSettings;
$thumb.removeClass('file-preview-success file-preview-error file-preview-loading');
if (status === 'Success') {
$thumb.find('.file-drag-handle').remove();
}
$indicator.html(config[icon]);
$indicator.attr('title', config[msg]);
$thumb.addClass(css);
if (status === 'Error' && !self.retryErrorUploads) {
$thumb.find('.kv-file-upload').attr('disabled', true);
}
},
_setProgressCancelled: function () {
var self = this;
self._setProgress(101, self.$progress, self.msgCancelled);
},
_setProgress: function (p, $el, error) {
var self = this, pct = Math.min(p, 100), out, pctLimit = self.progressUploadThreshold,
t = p <= 100 ? self.progressTemplate : self.progressCompleteTemplate,
template = pct < 100 ? self.progressTemplate : (error ? self.progressErrorTemplate : t);
$el = $el || self.$progress;
if (!$h.isEmpty(template)) {
if (pctLimit && pct > pctLimit && p <= 100) {
out = template.setTokens({'percent': pctLimit, 'status': self.msgUploadThreshold});
} else {
out = template.setTokens({'percent': pct, 'status': (p > 100 ? self.msgUploadEnd : pct + '%')});
}
$el.html(out);
if (error) {
$el.find('[role="progressbar"]').html(error);
}
}
},
_setFileDropZoneTitle: function () {
var self = this, $zone = self.$container.find('.file-drop-zone'), title = self.dropZoneTitle, strFiles;
if (self.isClickable) {
strFiles = $h.isEmpty(self.$element.attr('multiple')) ? self.fileSingle : self.filePlural;
title += self.dropZoneClickTitle.replace('{files}', strFiles);
}
$zone.find('.' + self.dropZoneTitleClass).remove();
if (!self.showPreview || $zone.length === 0 || self.getFileStack().length > 0 || !self.dropZoneEnabled ||
(!self.isAjaxUpload && self.$element.files)) {
return;
}
if ($zone.find($h.FRAMES).length === 0 && $h.isEmpty(self.defaultPreviewContent)) {
$zone.prepend('<div class="' + self.dropZoneTitleClass + '">' + title + '</div>');
}
self.$container.removeClass('file-input-new');
$h.addCss(self.$container, 'file-input-ajax-new');
},
_setAsyncUploadStatus: function (previewId, pct, total) {
var self = this, sum = 0;
self._setProgress(pct, $('#' + previewId).find('.file-thumb-progress'));
self.uploadStatus[previewId] = pct;
$.each(self.uploadStatus, function (key, value) {
sum += value;
});
self._setProgress(Math.floor(sum / total));
},
_validateMinCount: function () {
var self = this, len = self.isAjaxUpload ? self.getFileStack().length : self._inputFileCount();
if (self.validateInitialCount && self.minFileCount > 0 && self._getFileCount(len - 1) < self.minFileCount) {
self._noFilesError({});
return false;
}
return true;
},
_getFileCount: function (fileCount) {
var self = this, addCount = 0;
if (self.validateInitialCount && !self.overwriteInitial) {
addCount = self.previewCache.count();
fileCount += addCount;
}
return fileCount;
},
_getFileId: function (file) {
var self = this, custom = self.generateFileId, relativePath;
if (typeof custom === 'function') {
return custom(file, event);
}
if (!file) {
return null;
}
/** @namespace file.relativePath */
/** @namespace file.webkitRelativePath */
relativePath = String(file.relativePath || file.webkitRelativePath || $h.getFileName(file) || null);
if (!relativePath) {
return null;
}
return (file.size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/img, ''));
},
_getFileName: function (file, defaultValue) {
var self = this, fileName = $h.getFileName(file);
return fileName ? self.slug(fileName) : defaultValue;
},
_getFileIds: function (skipNull) {
var self = this;
return self.fileids.filter(function (n) {
return (skipNull ? n !== undefined : n !== undefined && n !== null);
});
},
_getFileNames: function (skipNull) {
var self = this;
return self.filenames.filter(function (n) {
return (skipNull ? n !== undefined : n !== undefined && n !== null);
});
},
_setPreviewError: function ($thumb, i, val, repeat) {
var self = this;
if (i !== undefined) {
self.updateStack(i, val);
}
if (!self.showPreview) {
return;
}
if (self.removeFromPreviewOnError && !repeat) {
$thumb.remove();
return;
} else {
self._setThumbStatus($thumb, 'Error');
}
self._refreshUploadButton($thumb, repeat);
},
_refreshUploadButton: function ($thumb, repeat) {
var self = this, $btn = $thumb.find('.kv-file-upload'), cfg = self.fileActionSettings,
icon = cfg.uploadIcon, title = cfg.uploadTitle;
if (!$btn.length) {
return;
}
if (repeat) {
icon = cfg.uploadRetryIcon;
title = cfg.uploadRetryTitle;
}
$btn.attr('title', title).html(icon);
},
_checkDimensions: function (i, chk, $img, $thumb, fname, type, params) {
var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type],
$imgEl, isValid;
if ($h.isEmpty(limit) || !$img.length) {
return;
}
$imgEl = $img[0];
dim = (type === 'Width') ? $imgEl.naturalWidth || $imgEl.width : $imgEl.naturalHeight || $imgEl.height;
isValid = chk === 'Small' ? dim >= limit : dim <= limit;
if (isValid) {
return;
}
msg = self['msgImage' + type + chk].setTokens({'name': fname, 'size': limit});
self._showUploadError(msg, params);
self._setPreviewError($thumb, i, null);
},
_getExifObj: function (data) {
var self = this, exifObj = null;
if (data.slice(0, 23) !== 'data:image/jpeg;base64,' && data.slice(0, 22) !== 'data:image/jpg;base64,') {
exifObj = null;
return;
}
try {
exifObj = window.piexif ? window.piexif.load(data) : null;
} catch (err) {
exifObj = null;
self._log(err);
}
if (!exifObj) {
self._log(
'The piexif.js library was not detected. Either load piexif.js on your page OR set `autoOrientImage` to `false`.');
}
return exifObj;
},
_validateImageOrientation: function ($img, file, previewId, caption, ftype, fsize, iData) {
var self = this, exifObj, value, autoOrientImage = self.autoOrientImage;
if (typeof autoOrientImage === 'function') {
autoOrientImage = autoOrientImage();
}
exifObj = $img.length && autoOrientImage ? self._getExifObj(iData) : null;
value = exifObj ? exifObj['0th'][piexif.ImageIFD.Orientation] : null; // jshint ignore:line
if (!value) {
self._validateImage(previewId, caption, ftype, fsize, iData, exifObj);
return;
}
$h.setImageOrientation($img, self.$preview.find('#zoom-' + previewId + ' img'), value);
self._raise('fileimageoriented', {'$img': $img, 'file': file});
self._validateImage(previewId, caption, ftype, fsize, iData, exifObj);
},
_validateImage: function (previewId, fname, ftype, fsize, iData, exifObj) {
var self = this, $preview = self.$preview, params, w1, w2, $thumb = $preview.find('#' + previewId),
i = $thumb.attr('data-fileindex'), $img = $thumb.find('img');
fname = fname || 'Untitled';
$img.one('load', function () {
w1 = $thumb.width();
w2 = $preview.width();
if (w1 > w2) {
$img.css('width', '100%');
}
params = {ind: i, id: previewId};
self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Width', params);
self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Height', params);
if (!self.resizeImage) {
self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Width', params);
self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Height', params);
}
self._raise('fileimageloaded', [previewId]);
self.loadedImages.push({
ind: i,
img: $img,
thumb: $thumb,
pid: previewId,
typ: ftype,
siz: fsize,
validated: false,
imgData: iData,
exifObj: exifObj
});
$thumb.data('exif', exifObj);
self._validateAllImages();
}).one('error', function () {
self._raise('fileimageloaderror', [previewId]);
}).each(function () {
if (this.complete) {
$(this).trigger('load');
} else {
if (this.error) {
$(this).trigger('error');
}
}
});
},
_validateAllImages: function () {
var self = this, i, counter = {val: 0}, numImgs = self.loadedImages.length, config,
fsize, minSize = self.resizeIfSizeMoreThan;
if (numImgs !== self.totalImagesCount) {
return;
}
self._raise('fileimagesloaded');
if (!self.resizeImage) {
return;
}
for (i = 0; i < self.loadedImages.length; i++) {
config = self.loadedImages[i];
if (config.validated) {
continue;
}
fsize = config.siz;
if (fsize && fsize > minSize * 1000) {
self._getResizedImage(config, counter, numImgs);
}
self.loadedImages[i].validated = true;
}
},
_getResizedImage: function (config, counter, numImgs) {
var self = this, img = $(config.img)[0], width = img.naturalWidth, height = img.naturalHeight, blob,
ratio = 1, maxWidth = self.maxImageWidth || width, maxHeight = self.maxImageHeight || height,
isValidImage = !!(width && height), chkWidth, chkHeight, canvas = self.imageCanvas, dataURI,
context = self.imageCanvasContext, type = config.typ, pid = config.pid, ind = config.ind,
$thumb = config.thumb, throwError, msg, exifObj = config.exifObj, exifStr;
throwError = function (msg, params, ev) {
if (self.isAjaxUpload) {
self._showUploadError(msg, params, ev);
} else {
self._showError(msg, params, ev);
}
self._setPreviewError($thumb, ind);
};
if (!self.filestack[ind] || !isValidImage || (width <= maxWidth && height <= maxHeight)) {
if (isValidImage && self.filestack[ind]) {
self._raise('fileimageresized', [pid, ind]);
}
counter.val++;
if (counter.val === numImgs) {
self._raise('fileimagesresized');
}
if (!isValidImage) {
throwError(self.msgImageResizeError, {id: pid, 'index': ind}, 'fileimageresizeerror');
return;
}
}
type = type || self.resizeDefaultImageType;
chkWidth = width > maxWidth;
chkHeight = height > maxHeight;
if (self.resizePreference === 'width') {
ratio = chkWidth ? maxWidth / width : (chkHeight ? maxHeight / height : 1);
} else {
ratio = chkHeight ? maxHeight / height : (chkWidth ? maxWidth / width : 1);
}
self._resetCanvas();
width *= ratio;
height *= ratio;
canvas.width = width;
canvas.height = height;
try {
context.drawImage(img, 0, 0, width, height);
dataURI = canvas.toDataURL(type, self.resizeQuality);
if (exifObj) {
exifStr = window.piexif.dump(exifObj);
dataURI = window.piexif.insert(exifStr, dataURI);
}
blob = $h.dataURI2Blob(dataURI);
self.filestack[ind] = blob;
self._raise('fileimageresized', [pid, ind]);
counter.val++;
if (counter.val === numImgs) {
self._raise('fileimagesresized', [undefined, undefined]);
}
if (!(blob instanceof Blob)) {
throwError(self.msgImageResizeError, {id: pid, 'index': ind}, 'fileimageresizeerror');
}
}
catch (err) {
counter.val++;
if (counter.val === numImgs) {
self._raise('fileimagesresized', [undefined, undefined]);
}
msg = self.msgImageResizeException.replace('{errors}', err.message);
throwError(msg, {id: pid, 'index': ind}, 'fileimageresizeexception');
}
},
_initBrowse: function ($container) {
var self = this, $el = self.$element;
if (self.showBrowse) {
self.$btnFile = $container.find('.btn-file').append($el);
} else {
$el.appendTo($container).attr('tabindex', -1);
$h.addCss($el, 'file-no-browse');
}
},
_initClickable: function () {
var self = this, $zone, $tmpZone;
if (!self.isClickable) {
return;
}
$zone = self.$dropZone;
if (!self.isAjaxUpload) {
$tmpZone = self.$preview.find('.file-default-preview');
if ($tmpZone.length) {
$zone = $tmpZone;
}
}
$h.addCss($zone, 'clickable');
$zone.attr('tabindex', -1);
self._handler($zone, 'click', function (e) {
var $tar = $(e.target);
if (!$(self.elErrorContainer + ':visible').length &&
(!$tar.parents('.file-preview-thumbnails').length || $tar.parents(
'.file-default-preview').length)) {
self.$element.data('zoneClicked', true).trigger('click');
$zone.blur();
}
});
},
_initCaption: function () {
var self = this, cap = self.initialCaption || '';
if (self.overwriteInitial || $h.isEmpty(cap)) {
self.$caption.val('');
return false;
}
self._setCaption(cap);
return true;
},
_setCaption: function (content, isError) {
var self = this, title, out, icon, n, cap, stack = self.getFileStack();
if (!self.$caption.length) {
return;
}
self.$captionContainer.removeClass('icon-visible');
if (isError) {
title = $('<div>' + self.msgValidationError + '</div>').text();
n = stack.length;
if (n) {
cap = n === 1 && stack[0] ? self._getFileNames()[0] : self._getMsgSelected(n);
} else {
cap = self._getMsgSelected(self.msgNo);
}
out = $h.isEmpty(content) ? cap : content;
icon = '<span class="' + self.msgValidationErrorClass + '">' + self.msgValidationErrorIcon + '</span>';
} else {
if ($h.isEmpty(content)) {
return;
}
title = $('<div>' + content + '</div>').text();
out = title;
icon = self._getLayoutTemplate('fileIcon');
}
self.$captionContainer.addClass('icon-visible');
self.$caption.attr('title', title).val(out);
self.$captionIcon.html(icon);
},
_createContainer: function () {
var self = this, attribs = {'class': 'file-input file-input-new' + (self.rtl ? ' kv-rtl' : '')},
$container = $(document.createElement('div')).attr(attribs).html(self._renderMain());
$container.insertBefore(self.$element);
self._initBrowse($container);
if (self.theme) {
$container.addClass('theme-' + self.theme);
}
return $container;
},
_refreshContainer: function () {
var self = this, $container = self.$container, $el = self.$element;
$el.insertAfter($container);
$container.html(self._renderMain());
self._initBrowse($container);
self._validateDisabled();
},
_validateDisabled: function () {
var self = this;
self.$caption.attr({readonly: self.isDisabled});
},
_renderMain: function () {
var self = this,
dropCss = self.dropZoneEnabled ? ' file-drop-zone' : 'file-drop-disabled',
close = !self.showClose ? '' : self._getLayoutTemplate('close'),
preview = !self.showPreview ? '' : self._getLayoutTemplate('preview')
.setTokens({'class': self.previewClass, 'dropClass': dropCss}),
css = self.isDisabled ? self.captionClass + ' file-caption-disabled' : self.captionClass,
caption = self.captionTemplate.setTokens({'class': css + ' kv-fileinput-caption'});
return self.mainTemplate.setTokens({
'class': self.mainClass + (!self.showBrowse && self.showCaption ? ' no-browse' : ''),
'preview': preview,
'close': close,
'caption': caption,
'upload': self._renderButton('upload'),
'remove': self._renderButton('remove'),
'cancel': self._renderButton('cancel'),
'browse': self._renderButton('browse')
});
},
_renderButton: function (type) {
var self = this, tmplt = self._getLayoutTemplate('btnDefault'), css = self[type + 'Class'],
title = self[type + 'Title'], icon = self[type + 'Icon'], label = self[type + 'Label'],
status = self.isDisabled ? ' disabled' : '', btnType = 'button';
switch (type) {
case 'remove':
if (!self.showRemove) {
return '';
}
break;
case 'cancel':
if (!self.showCancel) {
return '';
}
css += ' kv-hidden';
break;
case 'upload':
if (!self.showUpload) {
return '';
}
if (self.isAjaxUpload && !self.isDisabled) {
tmplt = self._getLayoutTemplate('btnLink').replace('{href}', self.uploadUrl);
} else {
btnType = 'submit';
}
break;
case 'browse':
if (!self.showBrowse) {
return '';
}
tmplt = self._getLayoutTemplate('btnBrowse');
break;
default:
return '';
}
css += type === 'browse' ? ' btn-file' : ' fileinput-' + type + ' fileinput-' + type + '-button';
if (!$h.isEmpty(label)) {
label = ' <span class="' + self.buttonLabelClass + '">' + label + '</span>';
}
return tmplt.setTokens({
'type': btnType, 'css': css, 'title': title, 'status': status, 'icon': icon, 'label': label
});
},
_renderThumbProgress: function () {
var self = this;
return '<div class="file-thumb-progress kv-hidden">' +
self.progressTemplate.setTokens({'percent': '0', 'status': self.msgUploadBegin}) +
'</div>';
},
_renderFileFooter: function (caption, size, width, isError) {
var self = this, config = self.fileActionSettings, rem = config.showRemove, drg = config.showDrag,
upl = config.showUpload, zoom = config.showZoom, out,
template = self._getLayoutTemplate('footer'), tInd = self._getLayoutTemplate('indicator'),
ind = isError ? config.indicatorError : config.indicatorNew,
title = isError ? config.indicatorErrorTitle : config.indicatorNewTitle,
indicator = tInd.setTokens({'indicator': ind, 'indicatorTitle': title});
size = self._getSize(size);
if (self.isAjaxUpload) {
out = template.setTokens({
'actions': self._renderFileActions(upl, false, rem, zoom, drg, false, false, false),
'caption': caption,
'size': size,
'width': width,
'progress': self._renderThumbProgress(),
'indicator': indicator
});
} else {
out = template.setTokens({
'actions': self._renderFileActions(false, false, false, zoom, drg, false, false, false),
'caption': caption,
'size': size,
'width': width,
'progress': '',
'indicator': indicator
});
}
out = $h.replaceTags(out, self.previewThumbTags);
return out;
},
_renderFileActions: function (
showUpl,
showDwn,
showDel,
showZoom,
showDrag,
disabled,
url,
key,
isInit,
dUrl,
dFile
) {
if (!showUpl && !showDwn && !showDel && !showZoom && !showDrag) {
return '';
}
var self = this, vUrl = url === false ? '' : ' data-url="' + url + '"',
vKey = key === false ? '' : ' data-key="' + key + '"', btnDelete = '', btnUpload = '', btnDownload = '',
btnZoom = '', btnDrag = '', css, template = self._getLayoutTemplate('actions'),
config = self.fileActionSettings,
otherButtons = self.otherActionButtons.setTokens({'dataKey': vKey, 'key': key}),
removeClass = disabled ? config.removeClass + ' disabled' : config.removeClass;
if (showDel) {
btnDelete = self._getLayoutTemplate('actionDelete').setTokens({
'removeClass': removeClass,
'removeIcon': config.removeIcon,
'removeTitle': config.removeTitle,
'dataUrl': vUrl,
'dataKey': vKey,
'key': key
});
}
if (showUpl) {
btnUpload = self._getLayoutTemplate('actionUpload').setTokens({
'uploadClass': config.uploadClass,
'uploadIcon': config.uploadIcon,
'uploadTitle': config.uploadTitle
});
}
if (showDwn) {
btnDownload = self._getLayoutTemplate('actionDownload').setTokens({
'downloadClass': config.downloadClass,
'downloadIcon': config.downloadIcon,
'downloadTitle': config.downloadTitle,
'downloadUrl': dUrl || self.initialPreviewDownloadUrl
});
btnDownload = btnDownload.setTokens({'filename': dFile, 'key': key});
}
if (showZoom) {
btnZoom = self._getLayoutTemplate('actionZoom').setTokens({
'zoomClass': config.zoomClass,
'zoomIcon': config.zoomIcon,
'zoomTitle': config.zoomTitle
});
}
if (showDrag && isInit) {
css = 'drag-handle-init ' + config.dragClass;
btnDrag = self._getLayoutTemplate('actionDrag').setTokens({
'dragClass': css,
'dragTitle': config.dragTitle,
'dragIcon': config.dragIcon
});
}
return template.setTokens({
'delete': btnDelete,
'upload': btnUpload,
'download': btnDownload,
'zoom': btnZoom,
'drag': btnDrag,
'other': otherButtons
});
},
_browse: function (e) {
var self = this;
if (e && e.isDefaultPrevented() || !self._raise('filebrowse')) {
return;
}
if (self.isError && !self.isAjaxUpload) {
self.clear();
}
self.$captionContainer.focus();
},
_filterDuplicate: function (file, files, fileIds) {
var self = this, fileId = self._getFileId(file);
if (fileId && fileIds && fileIds.indexOf(fileId) > -1) {
return;
}
if (!fileIds) {
fileIds = [];
}
files.push(file);
fileIds.push(fileId);
},
_change: function (e) {
var self = this;
if (self.changeTriggered) {
return;
}
var $el = self.$element, isDragDrop = arguments.length > 1, isAjaxUpload = self.isAjaxUpload,
tfiles = [], files = isDragDrop ? arguments[1] : $el.get(0).files, total,
maxCount = !isAjaxUpload && $h.isEmpty($el.attr('multiple')) ? 1 : self.maxFileCount,
len, ctr = self.filestack.length, isSingleUpload = $h.isEmpty($el.attr('multiple')),
flagSingle = (isSingleUpload && ctr > 0), fileIds = self._getFileIds(),
throwError = function (mesg, file, previewId, index) {
var p1 = $.extend(true, {}, self._getOutData({}, {}, files), {id: previewId, index: index}),
p2 = {id: previewId, index: index, file: file, files: files};
return isAjaxUpload ? self._showUploadError(mesg, p1) : self._showError(mesg, p2);
},
maxCountCheck = function (n, m) {
var msg = self.msgFilesTooMany.replace('{m}', m).replace('{n}', n);
self.isError = throwError(msg, null, null, null);
self.$captionContainer.removeClass('icon-visible');
self._setCaption('', true);
self.$container.removeClass('file-input-new file-input-ajax-new');
};
self.reader = null;
self._resetUpload();
self._hideFileIcon();
if (self.dropZoneEnabled) {
self.$container.find('.file-drop-zone .' + self.dropZoneTitleClass).remove();
}
if (isAjaxUpload) {
$.each(files, function (vKey, vFile) {
self._filterDuplicate(vFile, tfiles, fileIds);
});
} else {
if (e.target && e.target.files === undefined) {
files = e.target.value ? [{name: e.target.value.replace(/^.+\\/, '')}] : [];
} else {
files = e.target.files || {};
}
tfiles = files;
}
if ($h.isEmpty(tfiles) || tfiles.length === 0) {
if (!isAjaxUpload) {
self.clear();
}
self._raise('fileselectnone');
return;
}
self._resetErrors();
len = tfiles.length;
total = self._getFileCount(isAjaxUpload ? (self.getFileStack().length + len) : len);
if (maxCount > 0 && total > maxCount) {
if (!self.autoReplace || len > maxCount) {
maxCountCheck((self.autoReplace && len > maxCount ? len : total), maxCount);
return;
}
if (total > maxCount) {
self._resetPreviewThumbs(isAjaxUpload);
}
} else {
if (!isAjaxUpload || flagSingle) {
self._resetPreviewThumbs(false);
if (flagSingle) {
self.clearStack();
}
} else {
if (isAjaxUpload && ctr === 0 && (!self.previewCache.count() || self.overwriteInitial)) {
self._resetPreviewThumbs(true);
}
}
}
if (self.isPreviewable) {
self.readFiles(tfiles);
} else {
self._updateFileDetails(1);
}
},
_abort: function (params) {
var self = this, data;
if (self.ajaxAborted && typeof self.ajaxAborted === 'object' && self.ajaxAborted.message !== undefined) {
data = $.extend(true, {}, self._getOutData(), params);
data.abortData = self.ajaxAborted.data || {};
data.abortMessage = self.ajaxAborted.message;
self._setProgress(101, self.$progress, self.msgCancelled);
self._showUploadError(self.ajaxAborted.message, data, 'filecustomerror');
self.cancel();
return true;
}
return !!self.ajaxAborted;
},
_resetFileStack: function () {
var self = this, i = 0, newstack = [], newnames = [], newids = [];
self._getThumbs().each(function () {
var $thumb = $(this), ind = $thumb.attr('data-fileindex'), file = self.filestack[ind],
pid = $thumb.attr('id');
if (ind === '-1' || ind === -1) {
return;
}
if (file !== undefined) {
newstack[i] = file;
newnames[i] = self._getFileName(file);
newids[i] = self._getFileId(file);
$thumb.attr({'id': self.previewInitId + '-' + i, 'data-fileindex': i});
i++;
} else {
$thumb.attr({'id': 'uploaded-' + $h.uniqId(), 'data-fileindex': '-1'});
}
self.$preview.find('#zoom-' + pid).attr({
'id': 'zoom-' + $thumb.attr('id'),
'data-fileindex': $thumb.attr('data-fileindex')
});
});
self.filestack = newstack;
self.filenames = newnames;
self.fileids = newids;
},
_isFileSelectionValid: function (cnt) {
var self = this;
cnt = cnt || 0;
if (self.required && !self.getFilesCount()) {
self.$errorContainer.html('');
self._showUploadError(self.msgFileRequired);
return false;
}
if (self.minFileCount > 0 && self._getFileCount(cnt) < self.minFileCount) {
self._noFilesError({});
return false;
}
return true;
},
clearStack: function () {
var self = this;
self.filestack = [];
self.filenames = [];
self.fileids = [];
return self.$element;
},
updateStack: function (i, file) {
var self = this;
self.filestack[i] = file;
self.filenames[i] = self._getFileName(file);
self.fileids[i] = file && self._getFileId(file) || null;
return self.$element;
},
addToStack: function (file) {
var self = this;
self.filestack.push(file);
self.filenames.push(self._getFileName(file));
self.fileids.push(self._getFileId(file));
return self.$element;
},
getFileStack: function (skipNull) {
var self = this;
return self.filestack.filter(function (n) {
return (skipNull ? n !== undefined : n !== undefined && n !== null);
});
},
getFilesCount: function () {
var self = this, len = self.isAjaxUpload ? self.getFileStack().length : self._inputFileCount();
return self._getFileCount(len);
},
readFiles: function (files) {
this.reader = new FileReader();
var self = this, $el = self.$element, $preview = self.$preview, reader = self.reader,
$container = self.$previewContainer, $status = self.$previewStatus, msgLoading = self.msgLoading,
msgProgress = self.msgProgress, previewInitId = self.previewInitId, numFiles = files.length,
settings = self.fileTypeSettings, ctr = self.filestack.length, readFile,
fileTypes = self.allowedFileTypes, typLen = fileTypes ? fileTypes.length : 0,
fileExt = self.allowedFileExtensions, strExt = $h.isEmpty(fileExt) ? '' : fileExt.join(', '),
maxPreviewSize = self.maxFilePreviewSize && parseFloat(self.maxFilePreviewSize),
canPreview = $preview.length && (!maxPreviewSize || isNaN(maxPreviewSize)),
throwError = function (msg, file, previewId, index) {
var p1 = $.extend(true, {}, self._getOutData({}, {}, files), {id: previewId, index: index}),
p2 = {id: previewId, index: index, file: file, files: files}, $thumb;
self._previewDefault(file, previewId, true);
if (self.isAjaxUpload) {
self.addToStack(undefined);
setTimeout(function () {
readFile(index + 1);
}, 100);
} else {
numFiles = 0;
}
self._initFileActions();
$thumb = $('#' + previewId);
$thumb.find('.kv-file-upload').hide();
if (self.removeFromPreviewOnError) {
$thumb.remove();
}
self.isError = self.isAjaxUpload ? self._showUploadError(msg, p1) : self._showError(msg, p2);
self._updateFileDetails(numFiles);
};
self.loadedImages = [];
self.totalImagesCount = 0;
$.each(files, function (key, file) {
var func = self.fileTypeSettings.image;
if (func && func(file.type)) {
self.totalImagesCount++;
}
});
readFile = function (i) {
if ($h.isEmpty($el.attr('multiple'))) {
numFiles = 1;
}
if (i >= numFiles) {
if (self.isAjaxUpload && self.filestack.length > 0) {
self._raise('filebatchselected', [self.getFileStack()]);
} else {
self._raise('filebatchselected', [files]);
}
$container.removeClass('file-thumb-loading');
$status.html('');
return;
}
var node = ctr + i, previewId = previewInitId + '-' + node, file = files[i], fSizeKB, j, msg,
fnText = settings.text, fnImage = settings.image, fnHtml = settings.html, typ, chk, typ1, typ2,
caption = self._getFileName(file, ''), fileSize = (file && file.size || 0) / 1000,
fileExtExpr = '', previewData = $h.createObjectURL(file), fileCount = 0,
strTypes = '',
func, knownTypes = 0, isText, isHtml, isImage, txtFlag, processFileLoaded = function () {
var msg = msgProgress.setTokens({
'index': i + 1,
'files': numFiles,
'percent': 50,
'name': caption
});
setTimeout(function () {
$status.html(msg);
self._updateFileDetails(numFiles);
readFile(i + 1);
}, 100);
self._raise('fileloaded', [file, previewId, i, reader]);
};
if (!file) {
return;
}
if (typLen > 0) {
for (j = 0; j < typLen; j++) {
typ1 = fileTypes[j];
typ2 = self.msgFileTypes[typ1] || typ1;
strTypes += j === 0 ? typ2 : ', ' + typ2;
}
}
if (caption === false) {
readFile(i + 1);
return;
}
if (caption.length === 0) {
msg = self.msgInvalidFileName.replace('{name}', $h.htmlEncode($h.getFileName(file), '[unknown]'));
throwError(msg, file, previewId, i);
return;
}
if (!$h.isEmpty(fileExt)) {
fileExtExpr = new RegExp('\\.(' + fileExt.join('|') + ')$', 'i');
}
fSizeKB = fileSize.toFixed(2);
if (self.maxFileSize > 0 && fileSize > self.maxFileSize) {
msg = self.msgSizeTooLarge.setTokens({
'name': caption,
'size': fSizeKB,
'maxSize': self.maxFileSize
});
throwError(msg, file, previewId, i);
return;
}
if (self.minFileSize !== null && fileSize <= $h.getNum(self.minFileSize)) {
msg = self.msgSizeTooSmall.setTokens({
'name': caption,
'size': fSizeKB,
'minSize': self.minFileSize
});
throwError(msg, file, previewId, i);
return;
}
if (!$h.isEmpty(fileTypes) && $h.isArray(fileTypes)) {
for (j = 0; j < fileTypes.length; j += 1) {
typ = fileTypes[j];
func = settings[typ];
fileCount += !func || (typeof func !== 'function') ? 0 : (func(file.type,
$h.getFileName(file)) ? 1 : 0);
}
if (fileCount === 0) {
msg = self.msgInvalidFileType.setTokens({'name': caption, 'types': strTypes});
throwError(msg, file, previewId, i);
return;
}
}
if (fileCount === 0 && !$h.isEmpty(fileExt) && $h.isArray(fileExt) && !$h.isEmpty(fileExtExpr)) {
chk = $h.compare(caption, fileExtExpr);
fileCount += $h.isEmpty(chk) ? 0 : chk.length;
if (fileCount === 0) {
msg = self.msgInvalidFileExtension.setTokens({'name': caption, 'extensions': strExt});
throwError(msg, file, previewId, i);
return;
}
}
if (!self.showPreview) {
if (self.isAjaxUpload) {
self.addToStack(file);
}
setTimeout(function () {
readFile(i + 1);
self._updateFileDetails(numFiles);
}, 100);
self._raise('fileloaded', [file, previewId, i, reader]);
return;
}
if (!canPreview && fileSize > maxPreviewSize) {
self.addToStack(file);
$container.addClass('file-thumb-loading');
self._previewDefault(file, previewId);
self._initFileActions();
self._updateFileDetails(numFiles);
readFile(i + 1);
return;
}
if ($preview.length && FileReader !== undefined) {
isText = fnText(file.type, caption);
isHtml = fnHtml(file.type, caption);
isImage = fnImage(file.type, caption);
$status.html(msgLoading.replace('{index}', i + 1).replace('{files}', numFiles));
$container.addClass('file-thumb-loading');
reader.onerror = function (evt) {
self._errorHandler(evt, caption);
};
reader.onload = function (theFile) {
var hex, fileInfo, uint, byte, bytes = [], contents, mime, readTextImage = function (textFlag) {
var newReader = new FileReader();
newReader.onerror = function (theFileNew) {
self._errorHandler(theFileNew, caption);
};
newReader.onload = function (theFileNew) {
self._previewFile(i, file, theFileNew, previewId, previewData, fileInfo);
self._initFileActions();
processFileLoaded();
};
if (textFlag) {
newReader.readAsText(file, self.textEncoding);
} else {
newReader.readAsDataURL(file);
}
};
fileInfo = {'name': caption, 'type': file.type};
$.each(settings, function (k, f) {
if (k !== 'object' && k !== 'other' && typeof f === 'function' && f(file.type, caption)) {
knownTypes++;
}
});
if (knownTypes === 0) {// auto detect mime types from content if no known file types detected
uint = new Uint8Array(theFile.target.result);
for (j = 0; j < uint.length; j++) {
byte = uint[j].toString(16);
bytes.push(byte);
}
hex = bytes.join('').toLowerCase().substring(0, 8);
mime = $h.getMimeType(hex, '', '');
if ($h.isEmpty(mime)) { // look for ascii text content
contents = $h.arrayBuffer2String(reader.result);
mime = $h.isSvg(contents) ? 'image/svg+xml' : $h.getMimeType(hex, contents, file.type);
}
fileInfo = {'name': caption, 'type': mime};
isText = fnText(mime, '');
isHtml = fnHtml(mime, '');
isImage = fnImage(mime, '');
txtFlag = isText || isHtml;
if (txtFlag || isImage) {
readTextImage(txtFlag);
return;
}
}
self._previewFile(i, file, theFile, previewId, previewData, fileInfo);
self._initFileActions();
processFileLoaded();
};
reader.onprogress = function (data) {
if (data.lengthComputable) {
var fact = (data.loaded / data.total) * 100, progress = Math.ceil(fact);
msg = msgProgress.setTokens({
'index': i + 1,
'files': numFiles,
'percent': progress,
'name': caption
});
setTimeout(function () {
$status.html(msg);
}, 100);
}
};
if (isText || isHtml) {
reader.readAsText(file, self.textEncoding);
} else {
if (isImage) {
reader.readAsDataURL(file);
} else {
reader.readAsArrayBuffer(file);
}
}
} else {
self._previewDefault(file, previewId);
setTimeout(function () {
readFile(i + 1);
self._updateFileDetails(numFiles);
}, 100);
self._raise('fileloaded', [file, previewId, i, reader]);
}
self.addToStack(file);
};
readFile(0);
self._updateFileDetails(numFiles, false);
},
lock: function () {
var self = this;
self._resetErrors();
self.disable();
if (self.showRemove) {
self.$container.find('.fileinput-remove').hide();
}
if (self.showCancel) {
self.$container.find('.fileinput-cancel').show();
}
self._raise('filelock', [self.filestack, self._getExtraData()]);
return self.$element;
},
unlock: function (reset) {
var self = this;
if (reset === undefined) {
reset = true;
}
self.enable();
if (self.showCancel) {
self.$container.find('.fileinput-cancel').hide();
}
if (self.showRemove) {
self.$container.find('.fileinput-remove').show();
}
if (reset) {
self._resetFileStack();
}
self._raise('fileunlock', [self.filestack, self._getExtraData()]);
return self.$element;
},
cancel: function () {
var self = this, xhr = self.ajaxRequests, len = xhr.length, i;
if (len > 0) {
for (i = 0; i < len; i += 1) {
self.cancelling = true;
xhr[i].abort();
}
}
self._setProgressCancelled();
self._getThumbs().each(function () {
var $thumb = $(this), ind = $thumb.attr('data-fileindex');
$thumb.removeClass('file-uploading');
if (self.filestack[ind] !== undefined) {
$thumb.find('.kv-file-upload').removeClass('disabled').removeAttr('disabled');
$thumb.find('.kv-file-remove').removeClass('disabled').removeAttr('disabled');
}
self.unlock();
});
return self.$element;
},
clear: function () {
var self = this, cap;
if (!self._raise('fileclear')) {
return;
}
self.$btnUpload.removeAttr('disabled');
self._getThumbs().find('video,audio,img').each(function () {
$h.cleanMemory($(this));
});
self._clearFileInput();
self._resetUpload();
self.clearStack();
self._resetErrors(true);
if (self._hasInitialPreview()) {
self._showFileIcon();
self._resetPreview();
self._initPreviewActions();
self.$container.removeClass('file-input-new');
} else {
self._getThumbs().each(function () {
self._clearObjects($(this));
});
if (self.isAjaxUpload) {
self.previewCache.data = {};
}
self.$preview.html('');
cap = (!self.overwriteInitial && self.initialCaption.length > 0) ? self.initialCaption : '';
self.$caption.attr('title', '').val(cap);
$h.addCss(self.$container, 'file-input-new');
self._validateDefaultPreview();
}
if (self.$container.find($h.FRAMES).length === 0) {
if (!self._initCaption()) {
self.$captionContainer.removeClass('icon-visible');
}
}
self._hideFileIcon();
self._raise('filecleared');
self.$captionContainer.focus();
self._setFileDropZoneTitle();
return self.$element;
},
reset: function () {
var self = this;
if (!self._raise('filereset')) {
return;
}
self._resetPreview();
self.$container.find('.fileinput-filename').text('');
$h.addCss(self.$container, 'file-input-new');
if (self.getFrames().length || self.dropZoneEnabled) {
self.$container.removeClass('file-input-new');
}
self.clearStack();
self.formdata = {};
self._setFileDropZoneTitle();
return self.$element;
},
disable: function () {
var self = this;
self.isDisabled = true;
self._raise('filedisabled');
self.$element.attr('disabled', 'disabled');
self.$container.find('.kv-fileinput-caption').addClass('file-caption-disabled');
self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button')
.attr('disabled', true);
$h.addCss(self.$container.find('.btn-file'), 'disabled');
self._initDragDrop();
return self.$element;
},
enable: function () {
var self = this;
self.isDisabled = false;
self._raise('fileenabled');
self.$element.removeAttr('disabled');
self.$container.find('.kv-fileinput-caption').removeClass('file-caption-disabled');
self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button')
.removeAttr('disabled');
self.$container.find('.btn-file').removeClass('disabled');
self._initDragDrop();
return self.$element;
},
upload: function () {
var self = this, totLen = self.getFileStack().length, i, outData, len,
hasExtraData = !$.isEmptyObject(self._getExtraData());
if (!self.isAjaxUpload || self.isDisabled || !self._isFileSelectionValid(totLen)) {
return;
}
self._resetUpload();
if (totLen === 0 && !hasExtraData) {
self._showUploadError(self.msgUploadEmpty);
return;
}
self.$progress.show();
self.uploadCount = 0;
self.uploadStatus = {};
self.uploadLog = [];
self.lock();
self._setProgress(2);
if (totLen === 0 && hasExtraData) {
self._uploadExtraOnly();
return;
}
len = self.filestack.length;
self.hasInitData = false;
if (self.uploadAsync) {
outData = self._getOutData();
self._raise('filebatchpreupload', [outData]);
self.fileBatchCompleted = false;
self.uploadCache = {content: [], config: [], tags: [], append: true};
self.uploadAsyncCount = self.getFileStack().length;
for (i = 0; i < len; i++) {
self.uploadCache.content[i] = null;
self.uploadCache.config[i] = null;
self.uploadCache.tags[i] = null;
}
self.$preview.find('.file-preview-initial').removeClass($h.SORT_CSS);
self._initSortable();
self.cacheInitialPreview = self.getPreview();
for (i = 0; i < len; i++) {
if (self.filestack[i]) {
self._uploadSingle(i, true);
}
}
return;
}
self._uploadBatch();
return self.$element;
},
destroy: function () {
var self = this, $form = self.$form, $cont = self.$container, $el = self.$element, ns = self.namespace;
$(document).off(ns);
$(window).off(ns);
if ($form && $form.length) {
$form.off(ns);
}
if (self.isAjaxUpload) {
self._clearFileInput();
}
self._cleanup();
self._initPreviewCache();
$el.insertBefore($cont).off(ns).removeData();
$cont.off().remove();
return $el;
},
refresh: function (options) {
var self = this, $el = self.$element;
if (typeof options !== 'object' || $h.isEmpty(options)) {
options = self.options;
} else {
options = $.extend(true, {}, self.options, options);
}
self._init(options, true);
self._listen();
return $el;
},
zoom: function (frameId) {
var self = this, $frame = self._getFrame(frameId), $modal = self.$modal;
if (!$frame) {
return;
}
$h.initModal($modal);
$modal.html(self._getModalContent());
self._setZoomContent($frame);
$modal.modal('show');
self._initZoomButtons();
},
getExif: function (frameId) {
var self = this, $frame = self._getFrame(frameId);
return $frame && $frame.data('exif') || null;
},
getFrames: function (cssFilter) {
var self = this, $frames;
cssFilter = cssFilter || '';
$frames = self.$preview.find($h.FRAMES + cssFilter);
if (self.reversePreviewOrder) {
$frames = $($frames.get().reverse());
}
return $frames;
},
getPreview: function () {
var self = this;
return {
content: self.initialPreview,
config: self.initialPreviewConfig,
tags: self.initialPreviewThumbTags
};
}
};
$.fn.fileinput = function (option) {
if (!$h.hasFileAPISupport() && !$h.isIE(9)) {
return;
}
var args = Array.apply(null, arguments), retvals = [];
args.shift();
this.each(function () {
var self = $(this), data = self.data('fileinput'), options = typeof option === 'object' && option,
theme = options.theme || self.data('theme'), l = {}, t = {},
lang = options.language || self.data('language') || $.fn.fileinput.defaults.language || 'en', opt;
if (!data) {
if (theme) {
t = $.fn.fileinputThemes[theme] || {};
}
if (lang !== 'en' && !$h.isEmpty($.fn.fileinputLocales[lang])) {
l = $.fn.fileinputLocales[lang] || {};
}
opt = $.extend(true, {}, $.fn.fileinput.defaults, t, $.fn.fileinputLocales.en, l, options, self.data());
data = new FileInput(this, opt);
self.data('fileinput', data);
}
if (typeof option === 'string') {
retvals.push(data[option].apply(data, args));
}
});
switch (retvals.length) {
case 0:
return this;
case 1:
return retvals[0];
default:
return retvals;
}
};
$.fn.fileinput.defaults = {
language: 'en',
showCaption: true,
showBrowse: true,
showPreview: true,
showRemove: true,
showUpload: true,
showCancel: true,
showClose: true,
showUploadedThumbs: true,
browseOnZoneClick: false,
autoReplace: false,
autoOrientImage: function () { // applicable for JPEG images only and non ios safari
var ua = window.navigator.userAgent, webkit = !!ua.match(/WebKit/i),
iOS = !!ua.match(/iP(od|ad|hone)/i), iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
return !iOSSafari;
},
required: false,
rtl: false,
hideThumbnailContent: false,
encodeUrl: true,
generateFileId: null,
previewClass: '',
captionClass: '',
frameClass: 'krajee-default',
mainClass: 'file-caption-main',
mainTemplate: null,
purifyHtml: true,
fileSizeGetter: null,
initialCaption: '',
initialPreview: [],
initialPreviewDelimiter: '*$$*',
initialPreviewAsData: false,
initialPreviewFileType: 'image',
initialPreviewConfig: [],
initialPreviewThumbTags: [],
previewThumbTags: {},
initialPreviewShowDelete: true,
initialPreviewDownloadUrl: '',
removeFromPreviewOnError: false,
deleteUrl: '',
deleteExtraData: {},
overwriteInitial: true,
previewZoomButtonIcons: {
prev: '<i class="glyphicon glyphicon-triangle-left"></i>',
next: '<i class="glyphicon glyphicon-triangle-right"></i>',
toggleheader: '<i class="glyphicon glyphicon-resize-vertical"></i>',
fullscreen: '<i class="glyphicon glyphicon-fullscreen"></i>',
borderless: '<i class="glyphicon glyphicon-resize-full"></i>',
close: '<i class="glyphicon glyphicon-remove"></i>'
},
previewZoomButtonClasses: {
prev: 'btn btn-navigate',
next: 'btn btn-navigate',
toggleheader: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
fullscreen: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
borderless: 'btn btn-sm btn-kv btn-default btn-outline-secondary',
close: 'btn btn-sm btn-kv btn-default btn-outline-secondary'
},
previewTemplates: {},
previewContentTemplates: {},
preferIconicPreview: false,
preferIconicZoomPreview: false,
allowedPreviewTypes: undefined,
allowedPreviewMimeTypes: null,
allowedFileTypes: null,
allowedFileExtensions: null,
defaultPreviewContent: null,
customLayoutTags: {},
customPreviewTags: {},
previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
previewFileIconClass: 'file-other-icon',
previewFileIconSettings: {},
previewFileExtSettings: {},
buttonLabelClass: 'hidden-xs',
browseIcon: '<i class="glyphicon glyphicon-folder-open"></i>&nbsp;',
browseClass: 'btn btn-primary',
removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
removeClass: 'btn btn-default btn-secondary',
cancelIcon: '<i class="glyphicon glyphicon-ban-circle"></i>',
cancelClass: 'btn btn-default btn-secondary',
uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
uploadClass: 'btn btn-default btn-secondary',
uploadUrl: null,
uploadUrlThumb: null,
uploadAsync: true,
uploadExtraData: {},
zoomModalHeight: 480,
minImageWidth: null,
minImageHeight: null,
maxImageWidth: null,
maxImageHeight: null,
resizeImage: false,
resizePreference: 'width',
resizeQuality: 0.92,
resizeDefaultImageType: 'image/jpeg',
resizeIfSizeMoreThan: 0, // in KB
minFileSize: 0,
maxFileSize: 0,
maxFilePreviewSize: 25600, // 25 MB
minFileCount: 0,
maxFileCount: 0,
validateInitialCount: false,
msgValidationErrorClass: 'text-danger',
msgValidationErrorIcon: '<i class="glyphicon glyphicon-exclamation-sign"></i> ',
msgErrorClass: 'file-error-message',
progressThumbClass: 'progress-bar bg-success progress-bar-success progress-bar-striped active',
progressClass: 'progress-bar bg-success progress-bar-success progress-bar-striped active',
progressCompleteClass: 'progress-bar bg-success progress-bar-success',
progressErrorClass: 'progress-bar bg-danger progress-bar-danger',
progressUploadThreshold: 99,
previewFileType: 'image',
elCaptionContainer: null,
elCaptionText: null,
elPreviewContainer: null,
elPreviewImage: null,
elPreviewStatus: null,
elErrorContainer: null,
errorCloseButton: $h.closeButton('kv-error-close'),
slugCallback: null,
dropZoneEnabled: true,
dropZoneTitleClass: 'file-drop-zone-title',
fileActionSettings: {},
otherActionButtons: '',
textEncoding: 'UTF-8',
ajaxSettings: {},
ajaxDeleteSettings: {},
showAjaxErrorDetails: true,
mergeAjaxCallbacks: false,
mergeAjaxDeleteCallbacks: false,
retryErrorUploads: true,
reversePreviewOrder: false
};
// noinspection HtmlUnknownAttribute
$.fn.fileinputLocales.en = {
fileSingle: 'file',
filePlural: 'files',
browseLabel: 'Browse &hellip;',
removeLabel: 'Remove',
removeTitle: 'Clear selected files',
cancelLabel: 'Cancel',
cancelTitle: 'Abort ongoing upload',
uploadLabel: 'Upload',
uploadTitle: 'Upload selected files',
msgNo: 'No',
msgNoFilesSelected: 'No files selected',
msgCancelled: 'Cancelled',
msgPlaceholder: 'Select {files}...',
msgZoomModalHeading: 'Detailed Preview',
msgFileRequired: 'You must select a file to upload.',
msgSizeTooSmall: 'File "{name}" (<b>{size} KB</b>) is too small and must be larger than <b>{minSize} KB</b>.',
msgSizeTooLarge: 'File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>.',
msgFilesTooLess: 'You must select at least <b>{n}</b> {files} to upload.',
msgFilesTooMany: 'Number of files selected for upload <b>({n})</b> exceeds maximum allowed limit of <b>{m}</b>.',
msgFileNotFound: 'File "{name}" not found!',
msgFileSecured: 'Security restrictions prevent reading the file "{name}".',
msgFileNotReadable: 'File "{name}" is not readable.',
msgFilePreviewAborted: 'File preview aborted for "{name}".',
msgFilePreviewError: 'An error occurred while reading the file "{name}".',
msgInvalidFileName: 'Invalid or unsupported characters in file name "{name}".',
msgInvalidFileType: 'Invalid type for file "{name}". Only "{types}" files are supported.',
msgInvalidFileExtension: 'Invalid extension for file "{name}". Only "{extensions}" files are supported.',
msgFileTypes: {
'image': 'image',
'html': 'HTML',
'text': 'text',
'video': 'video',
'audio': 'audio',
'flash': 'flash',
'pdf': 'PDF',
'object': 'object'
},
msgUploadAborted: 'The file upload was aborted',
msgUploadThreshold: 'Processing...',
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgUploadError: 'Error',
msgValidationError: 'Validation Error',
msgLoading: 'Loading file {index} of {files} &hellip;',
msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
msgSelected: '{n} {files} selected',
msgFoldersNotAllowed: 'Drag & drop files only! {n} folder(s) dropped were skipped.',
msgImageWidthSmall: 'Width of image file "{name}" must be at least {size} px.',
msgImageHeightSmall: 'Height of image file "{name}" must be at least {size} px.',
msgImageWidthLarge: 'Width of image file "{name}" cannot exceed {size} px.',
msgImageHeightLarge: 'Height of image file "{name}" cannot exceed {size} px.',
msgImageResizeError: 'Could not get the image dimensions to resize.',
msgImageResizeException: 'Error while resizing the image.<pre>{errors}</pre>',
msgAjaxError: 'Something went wrong with the {operation} operation. Please try again later!',
msgAjaxProgressError: '{operation} failed',
ajaxOperations: {
deleteThumb: 'file delete',
uploadThumb: 'file upload',
uploadBatch: 'batch file upload',
uploadExtra: 'form data upload'
},
dropZoneTitle: 'Drag & drop files here &hellip;',
dropZoneClickTitle: '<br>(or click to select {files})',
previewZoomButtonTitles: {
prev: 'View previous file',
next: 'View next file',
toggleheader: 'Toggle header',
fullscreen: 'Toggle full screen',
borderless: 'Toggle borderless mode',
close: 'Close detailed preview'
},
usePdfRenderer: function () {
//noinspection JSUnresolvedVariable
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
return !!navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/i) || isIE11;
},
pdfRendererUrl: '',
pdfRendererTemplate: '<iframe class="kv-preview-data file-preview-pdf" src="{renderer}?file={data}" {style}></iframe>'
};
$.fn.fileinput.Constructor = FileInput;
/**
* Convert automatically file inputs with class 'file' into a bootstrap fileinput control.
*/
$(document).ready(function () {
var $input = $('input.file[type=file]');
if ($input.length) {
$input.fileinput();
}
});
}));
/***/ }),
/* 8 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 9 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 10 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 11 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 12 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ })
/******/ ]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgNzcwOWI5OGU3OTRlZWE2MzY5YjQiLCJ3ZWJwYWNrOi8vLy4vbm9kZV9tb2R1bGVzL2pxdWVyeS9kaXN0L2pxdWVyeS5qcyIsIndlYnBhY2s6Ly8v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pcy5fZWxlbWVudC5jbGFzc0xpc3QuYWRkKENsYXNzTmFtZSQyLlBPSU5URVJfRVZFTlQpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgJCh0aGlzLl9lbGVtZW50KS5vbihFdmVudCQyLlRPVUNIU1RBUlQsIGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgIHJldHVybiBzdGFydChldmVudCk7XG4gICAgICAgIH0pO1xuICAgICAgICAkKHRoaXMuX2VsZW1lbnQpLm9uKEV2ZW50JDIuVE9VQ0hNT1ZFLCBmdW5jdGlvbiAoZXZlbnQpIHtcbiAgICAgICAgICByZXR1cm4gbW92ZShldmVudCk7XG4gICAgICAgIH0pO1xuICAgICAgICAkKHRoaXMuX2VsZW1lbnQpLm9uKEV2ZW50JDIuVE9VQ0hFTkQsIGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgIHJldHVybiBlbmQoZXZlbnQpO1xuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9O1xuXG4gICAgX3Byb3RvLl9rZXlkb3duID0gZnVuY3Rpb24gX2tleWRvd24oZXZlbnQpIHtcbiAgICAgIGlmICgvaW5wdXR8dGV4dGFyZWEvaS50ZXN0KGV2ZW50LnRhcmdldC50YWdOYW1lKSkge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIHN3aXRjaCAoZXZlbnQud2hpY2gpIHtcbiAgICAgICAgY2FzZSBBUlJPV19MRUZUX0tFWUNPREU6XG4gICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICB0aGlzLnByZXYoKTtcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBjYXNlIEFSUk9XX1JJR0hUX0tFWUNPREU6XG4gICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICB0aGlzLm5leHQoKTtcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBkZWZhdWx0OlxuICAgICAgfVxuICAgIH07XG5cbiAg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G4gICAgICAgIHBsYWNlbWVudDogdGhpcy5fZ2V0UGxhY2VtZW50KCksXG4gICAgICAgIG1vZGlmaWVyczoge1xuICAgICAgICAgIG9mZnNldDogdGhpcy5fZ2V0T2Zmc2V0KCksXG4gICAgICAgICAgZmxpcDoge1xuICAgICAgICAgICAgZW5hYmxlZDogdGhpcy5fY29uZmlnLmZsaXBcbiAgICAgICAgICB9LFxuICAgICAgICAgIHByZXZlbnRPdmVyZmxvdzoge1xuICAgICAgICAgICAgYm91bmRhcmllc0VsZW1lbnQ6IHRoaXMuX2NvbmZpZy5ib3VuZGFyeVxuICAgICAgICAgIH1cbiAgICAgICAgfSAvLyBEaXNhYmxlIFBvcHBlci5qcyBpZiB3ZSBoYXZlIGEgc3RhdGljIGRpc3BsYXlcblxuICAgICAgfTtcblxuICAgICAgaWYgKHRoaXMuX2NvbmZpZy5kaXNwbGF5ID09PSAnc3RhdGljJykge1xuICAgICAgICBwb3BwZXJDb25maWcubW9kaWZpZXJzLmFwcGx5U3R5bGUgPSB7XG4gICAgICAgICAgZW5hYmxlZDogZmFsc2VcbiAgICAgICAgfTtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHBvcHBlckNvbmZpZztcbiAgICB9IC8vIFN0YXRpY1xuICAgIDtcblxuICAgIERyb3Bkb3duLl9qUXVlcnlJbnRlcmZhY2UgPSBmdW5jdGlvbiBfalF1ZXJ5SW50ZXJmYWNlKGNvbmZpZykge1xuICAgICAgcmV0dXJuIHRoaXMuZWFjaChmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBkYXRhID0gJCh0aGlzKS5kYXRhKERBVEFfS0VZJDQpO1xuXG4gICAgICAgIHZhciBfY29uZmlnID0gdHlwZW9mIGNvbmZpZyA9PT0gJ29iamVjdCcgPyBjb25maWcgOiBudWxsO1xuXG4gICAgICAgIGlmICghZGF0YSkge1xuICAgICAgICAgIGRhdGEgPSBuZXcgRHJvcGRvd24odGhpcywgX2NvbmZpZyk7XG4gICAgICAgICAg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PyBDbGFzc05hbWUkNS5GQURFIDogJyc7XG5cbiAgICAgIGlmICh0aGlzLl9pc1Nob3duICYmIHRoaXMuX2NvbmZpZy5iYWNrZHJvcCkge1xuICAgICAgICB0aGlzLl9iYWNrZHJvcCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpO1xuICAgICAgICB0aGlzLl9iYWNrZHJvcC5jbGFzc05hbWUgPSBDbGFzc05hbWUkNS5CQUNLRFJPUDtcblxuICAgICAgICBpZiAoYW5pbWF0ZSkge1xuICAgICAgICAgIHRoaXMuX2JhY2tkcm9wLmNsYXNzTGlzdC5hZGQoYW5pbWF0ZSk7XG4gICAgICAgIH1cblxuICAgICAgICAkKHRoaXMuX2JhY2tkcm9wKS5hcHBlbmRUbyhkb2N1bWVudC5ib2R5KTtcbiAgICAgICAgJCh0aGlzLl9lbGVtZW50KS5vbihFdmVudCQ1LkNMSUNLX0RJU01JU1MsIGZ1bmN0aW9uIChldmVudCkge1xuICAgICAgICAgIGlmIChfdGhpczguX2lnbm9yZUJhY2tkcm9wQ2xpY2spIHtcbiAgICAgICAgICAgIF90aGlzOC5faWdub3JlQmFja2Ryb3BDbGljayA9IGZhbHNlO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IGV2ZW50LmN1cnJlbnRUYXJnZXQpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoX3RoaXM4Ll9jb25maWcuYmFja2Ryb3AgPT09ICdzdGF0aWMnKSB7XG4gICAgICAgICAgICBfdGhpczguX2VsZW1lbnQuZm9jdXMoKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgX3RoaXM4LmhpZGUoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGlmIChhbmltYXRlKSB7XG4gICAgICAgICAgVXRpbC5yZWZsb3codGh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VsZW1lbnQsIGNvbnRlbnQpIHtcbiAgICAgIGlmICh0eXBlb2YgY29udGVudCA9PT0gJ29iamVjdCcgJiYgKGNvbnRlbnQubm9kZVR5cGUgfHwgY29udGVudC5qcXVlcnkpKSB7XG4gICAgICAgIC8vIENvbnRlbnQgaXMgYSBET00gbm9kZSBvciBhIGpRdWVyeVxuICAgICAgICBpZiAodGhpcy5jb25maWcuaHRtbCkge1xuICAgICAgICAgIGlmICghJChjb250ZW50KS5wYXJlbnQoKS5pcygkZWxlbWVudCkpIHtcbiAgICAgICAgICAgICRlbGVtZW50LmVtcHR5KCkuYXBwZW5kKGNvbnRlbnQpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAkZWxlbWVudC50ZXh0KCQoY29udGVudCkudGV4dCgpKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKHRoaXMuY29uZmlnLmh0bWwpIHtcbiAgICAgICAgaWYgKHRoaXMuY29uZmlnLnNhbml0aXplKSB7XG4gICAgICAgICAgY29udGVudCA9IHNhbml0aXplSHRtbChjb250ZW50LCB0aGlzLmNvbmZpZy53aGl0ZUxpc3QsIHRoaXMuY29uZmlnLnNhbml0aXplRm4pO1xuICAgICAgICB9XG5cbiAgICAgICAgJGVsZW1lbnQuaHRtbChjb250ZW50KTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgICRlbGVtZW50LnRleHQoY29udGVudCk7XG4gICAgICB9XG4gICAgfTtcblxuICAgIF9wcm90by5nZXRUaXRsZSA9IGZ1bmN0aW9uIGdldFRpdGxlKCkge1xuICAgICAgdmFyIHRpdGxlID0gdGhpcy5lbGVtZW50LmdldEF0dHJpYnV0ZSgnZGF0YS1vcmlnaW5hbC10aXRsZScpO1xuXG4gICAgICBpZiAoIXRpdGxlKSB7XG4gICAgICAgIHRpdGxlID0gdHlwZW9mIHRoaXMuY29uZmlnLnRpdGxlID09PSAnZnVuY3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Vykge1xuICAgICAgICBjb250ZXh0Ll9ob3ZlclN0YXRlID0gSG92ZXJTdGF0ZS5TSE9XO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGNsZWFyVGltZW91dChjb250ZXh0Ll90aW1lb3V0KTtcbiAgICAgIGNvbnRleHQuX2hvdmVyU3RhdGUgPSBIb3ZlclN0YXRlLlNIT1c7XG5cbiAgICAgIGlmICghY29udGV4dC5jb25maWcuZGVsYXkgfHwgIWNvbnRleHQuY29uZmlnLmRlbGF5LnNob3cpIHtcbiAgICAgICAgY29udGV4dC5zaG93KCk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgY29udGV4dC5fdGltZW91dCA9IHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAoY29udGV4dC5faG92ZXJTdGF0ZSA9PT0gSG92ZXJTdGF0ZS5TSE9XKSB7XG4gICAgICAgICAgY29udGV4dC5zaG93KCk7XG4gICAgICAgIH1cbiAgICAgIH0sIGNvbnRleHQuY29uZmlnLmRlbGF5LnNob3cpO1xuICAgIH07XG5cbiAgICBfcHJvdG8uX2xlYXZlID0gZnVuY3Rpb24gX2xlYXZlKGV2ZW50LCBjb250ZXh0KSB7XG4gICAgICB2YXIgZGF0YUtleSA9IHRoaXMuY29uc3RydWN0b3IuREFUQV9LRVk7XG4gICAgICBjb250ZXh0ID0gY29udGV4dCB8fCAkKGV2ZW50LmN1cnJlbnRUYXJnZXQpLmRhdGEoZGF0YUtleSk7XG5cbiAgICAgIGlmICghY29udGV4dCkge1xuICAgICAgICBjb250ZXh0ID0gbmV3IHRoaXMuY29uc3RydWN0b3IoZXZlbnQuY3VycmVudFRhcmdldCwgdGhpcy5fZ2V0RGVsZWdhdGVDb25maWcoKSk7XG4gICAgICAgICQoZXZlbnQuY3VycmVudFRhcmdldCkuZGF0YShkYXRhS2V5LCBjb250ZXh0KTtcbiAgICAgIH1cblxuICAgICAgaWYgKGV2ZW50KSB7X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AgICcqJzogWydjbGFzcycsICdkaXInLCAnaWQnLCAnbGFuZycsICdyb2xlJywgJ3RhYmluZGV4JywgJ3N0eWxlJywgQVJJQV9BVFRSSUJVVEVfUEFUVEVSTl0sXHJcbiAgICBhOiBbJ3RhcmdldCcsICdocmVmJywgJ3RpdGxlJywgJ3JlbCddLFxyXG4gICAgYXJlYTogW10sXHJcbiAgICBiOiBbXSxcclxuICAgIGJyOiBbXSxcclxuICAgIGNvbDogW10sXHJcbiAgICBjb2RlOiBbXSxcclxuICAgIGRpdjogW10sXHJcbiAgICBlbTogW10sXHJcbiAgICBocjogW10sXHJcbiAgICBoMTogW10sXHJcbiAgICBoMjogW10sXHJcbiAgICBoMzogW10sXHJcbiAgICBoNDogW10sXHJcbiAgICBoNTogW10sXHJcbiAgICBoNjogW10sXHJcbiAgICBpOiBbXSxcclxuICAgIGltZzogWydzcmMnLCAnYWx0JywgJ3RpdGxlJywgJ3dpZHRoJywgJ2hlaWdodCddLFxyXG4gICAgbGk6IFtdLFxyXG4gICAgb2w6IFtdLFxyXG4gICAgcDogW10sXHJcbiAgICBwcmU6IFtdLFxyXG4gICAgczogW10sXHJcbiAgICBzbWFsbDogW10sXHJcbiAgICBzcGFuOiBbXSxcclxuICAgIHN1YjogW10sXHJcbiAgICBzdXA6IFtdLFxyXG4gICAgc3Ryb25nOiBbXSxcclxuICAgIHU6IFtdLFxyXG4gICAgdWw6IFtdXHJcbiAgfVxyXG5cclxuICAvKipcclxuICAgKiBBIHBhdHRlcm4gdGhhdCByZWNvZ25pemVzIGEgY29tbW9ubHkgdXNlZnVsIHN1YnNldCBvZiBVUkxzIHRoYXQgYXJlIHNhZmUuXHJcbiAgICpcclxuICAgKiBTaG91dG91dCB0byBBbmd1bGFyIDcgaHR0cHM6Ly9naXRodWIuY29tL2FuZ3VsYXIvYW5ndWxhci9ibG9iLzcuMi40L3BhY2thZ2VzL2NvcmUvc3JjL3Nhbml0aXphdGlvbi91cmxfc2FuaXRpemVyLnRzXHJc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pc3Qgc3VwcG9ydFxyXG4gIC8vIFJlbW92ZSBpbiB2MlxyXG4gIGlmICghKCdjbGFzc0xpc3QnIGluIGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ18nKSkpIHtcclxuICAgIChmdW5jdGlvbiAodmlldykge1xyXG4gICAgICBpZiAoISgnRWxlbWVudCcgaW4gdmlldykpIHJldHVybjtcclxuXHJcbiAgICAgIHZhciBjbGFzc0xpc3RQcm9wID0gJ2NsYXNzTGlzdCcsXHJcbiAgICAgICAgICBwcm90b1Byb3AgPSAncHJvdG90eXBlJyxcclxuICAgICAgICAgIGVsZW1DdHJQcm90byA9IHZpZXcuRWxlbWVudFtwcm90b1Byb3BdLFxyXG4gICAgICAgICAgb2JqQ3RyID0gT2JqZWN0LFxyXG4gICAgICAgICAgY2xhc3NMaXN0R2V0dGVyID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgJGVsZW0gPSAkKHRoaXMpO1xyXG5cclxuICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICBhZGQ6IGZ1bmN0aW9uIChjbGFzc2VzKSB7XHJcbiAgICAgICAgICAgICAgICBjbGFzc2VzID0gQXJyYXkucHJvdG90eXBlLnNsaWNlLmNhbGwoYXJndW1lbnRzKS5qb2luKCcgJyk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gJGVsZW0uYWRkQ2xhc3MoY2xhc3Nlcyk7XHJcbiAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICByZW1vdmU6IGZ1bmN0aW9uIChjbGFzc2VzKSB7XHJcbiAgICAgICAgICAgICAgICBjbGFzc2VzID0gQXJyYXkucHJvdG90eXBlLnNsaWNlLmNhbGwoYXJndW1lbnRzKS5qb2luKCcgJyk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gJGVsZW0ucmVtb3ZlQ2xhc3MoY2xhc3Nlcyk7XHJcbiAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICB0b2d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IHNlYXJjaFN0cmluZy5jaGFyQ29kZUF0KGluZGV4KSkge1xyXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICB9O1xyXG4gICAgICBpZiAoZGVmaW5lUHJvcGVydHkpIHtcclxuICAgICAgICBkZWZpbmVQcm9wZXJ0eShTdHJpbmcucHJvdG90eXBlLCAnc3RhcnRzV2l0aCcsIHtcclxuICAgICAgICAgICd2YWx1ZSc6IHN0YXJ0c1dpdGgsXHJcbiAgICAgICAgICAnY29uZmlndXJhYmxlJzogdHJ1ZSxcclxuICAgICAgICAgICd3cml0YWJsZSc6IHRydWVcclxuICAgICAgICB9KTtcclxuICAgICAgfSBlbHNlIHtcclxuICAgICAgICBTdHJpbmcucHJvdG90eXBlLnN0YXJ0c1dpdGggPSBzdGFydHNXaXRoO1xyXG4gICAgICB9XHJcbiAgICB9KCkpO1xyXG4gIH1cclxuXHJcbiAgaWYgKCFPYmplY3Qua2V5cykge1xyXG4gICAgT2JqZWN0LmtleXMgPSBmdW5jdGlvbiAoXHJcbiAgICAgIG8sIC8vIG9iamVjdFxyXG4gICAgICBrLCAvLyBrZXlcclxuICAgICAgciAgLy8gcmVzdWx0IGFycmF5XHJcbiAgICApIHtcclxuICAgICAgLy8gaW5pdGlhbGl6ZSBvYmplY3QgYW5kIHJlc3VsdFxyXG4gICAgICByID0gW107XHJcbiAgICAgIC8vIGl0ZXJhdGUgb3ZlciBvYmplY3Qga2V5c1xyXG4gICAgICBmb3IgKGsgaW4gbykge1xyXG4gICAgICAgIC8vIGZpbGwgcmVzdWx0IGFycmF5IHdpdGggbm9uLXByb3RvdHlwaWNhbCBrZXlzXHJcbiAgICAgICAgci5oYXNPd25Qcm9wZXJ0eS5jYWxsKG8sIGspICYmIHIucHVzaChrKTtcclxuICAgICAgfVxyXG4gICAgICAvLyByZXR1cm4gcmVzdWx0XHJcbiA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xsIGJ0biAnICsgY2xhc3NOYW1lcy5CVVRUT05DTEFTUyArICdcIj4nICtcclxuICAgICAgICAgICAgICAgIHRoaXMub3B0aW9ucy5zZWxlY3RBbGxUZXh0ICtcclxuICAgICAgICAgICAgICAnPC9idXR0b24+JyArXHJcbiAgICAgICAgICAgICAgJzxidXR0b24gdHlwZT1cImJ1dHRvblwiIGNsYXNzPVwiYWN0aW9ucy1idG4gYnMtZGVzZWxlY3QtYWxsIGJ0biAnICsgY2xhc3NOYW1lcy5CVVRUT05DTEFTUyArICdcIj4nICtcclxuICAgICAgICAgICAgICAgIHRoaXMub3B0aW9ucy5kZXNlbGVjdEFsbFRleHQgK1xyXG4gICAgICAgICAgICAgICc8L2J1dHRvbj4nICtcclxuICAgICAgICAgICAgJzwvZGl2PicgK1xyXG4gICAgICAgICAgJzwvZGl2Pic7XHJcbiAgICAgIH1cclxuXHJcbiAgICAgIGlmICh0aGlzLm11bHRpcGxlICYmIHRoaXMub3B0aW9ucy5kb25lQnV0dG9uKSB7XHJcbiAgICAgICAgZG9uZWJ1dHRvbiA9XHJcbiAgICAgICAgICAnPGRpdiBjbGFzcz1cImJzLWRvbmVidXR0b25cIj4nICtcclxuICAgICAgICAgICAgJzxkaXYgY2xhc3M9XCJidG4tZ3JvdXAgYnRuLWJsb2NrXCI+JyArXHJcbiAgICAgICAgICAgICAgJzxidXR0b24gdHlwZT1cImJ1dHRvblwiIGNsYXNzPVwiYnRuIGJ0bi1zbSAnICsgY2xhc3NOYW1lcy5CVVRUT05DTEFTUyArICdcIj4nICtcclxuICAgICAgICAgICAgICAgIHRoaXMub3B0aW9ucy5kb25lQnV0dG9uVGV4dCArXHJcbiAgICAgICAgICAgICAgJzwvYnV0dG9uPicgK1xyXG4gICAgICAgICAgICAnPC9kaXY+JyArXHJcbiAgICAgICAgICAnPC9kaXY+JztcclxuICAgICAgfVxyXG5cclxuICAgICAgZHJvcCA9XHJcbiAgICAgICAgJzxkaXYgY2xhc3M9XCJkcm9wZG93biBib290c3RyYXAtc2VsZWN0JyArIHNob3dUaWNrICsgaW5wdXRHcm91cCArICdcIj4nICtcclxuICAgICAgICAgICc8YnV0dG9uIHR5cGU9XCJidXR0b25cIiBjbGFzcz1cIicgKyB0aGlzLm9wdGlvbnMuc3R5bGVCYXNlICsgJyBkcm9wZG93bi10b2dnbGVcIiAnICsgKHRoaXMub3B0aW9ucy5kaXNwbGF5ID09PSAnc3RhdGljJyA/ICdkYXRhLWRpc3BsYXk9XCJzdGF0aWNcIicgOiAnJykgKyAnZGF0YS10b2dnbGU9XCJkcm9wZG93blwiJyArIGF1dG9mb2N1cyArICcgcm9sZT1cImNvbWJvYm94XCIgYXJpYS1vd25zPVwiJyArIHRoaXMuc2VsZWN0SWQgKyAnXCIgYXJpYS1oYXNwb3B1cD1cImxpc3Rib3hcIiBhcmlhLWV4cGFuZGVkPVwiZmFsc2VcIj4nICtcclxuICAgICAgICAgICAgJzxkaXYgY2xhc3M9XCJmaWx0ZXItb3B0aW9uXCI+JyArXHJcbiAgICAgICAgICAgICAgJzxkaXYgY2xhc3M9XCJmaWx0ZXItb3B0aW9uLWlubmVyXCI+JyArXHJcbiAgICAgICAgICAgICAgICAnPGRpdiBjbGFzcz1cImZpbHRlci1vcHRpb24taW5uZXItaW5uZXJcIj48L2Rpdj4nICtcclxuICAgICAgICAgICAgICAnPC9kaXY+ICcgK1xyXG4gICAgICAgICAgICAnPC9kaXY+JyArXHJcbiAgICAgICAgICAgIChcclxuICAgICAgICAgICAgICB2ZXJzaW9uLm1ham9yID09PSAnNCcgPyAnJ1xyXG4gICAgICAgICAgICAgIDpcclxuICAgICAgICAgICAgICAnPHNwYW4gY2xhc3M9XCJicy1jYXJldFwiPicgK1xyXG4gICAgICAgICAgICAgICAgdGhpcy5vcHRpb25zLnRlbXBsYXRlLmNhcmV0ICtcclxuICAgICAgICAgICAgICAnPC9zcGFuPidcclxuICAgICAgICAgICAgKSArXHJcbiAgICAgICAgICAnPC9idXR0b24+JyArXHJcbiA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pY2tlci5jdXJyZW50LmVsZW1lbnRzLmxlbmd0aCxcclxuICAgICAgICAgICAgY2h1bmtzID0gW10sXHJcbiAgICAgICAgICAgIGNodW5rU2l6ZSxcclxuICAgICAgICAgICAgY2h1bmtDb3VudCxcclxuICAgICAgICAgICAgZmlyc3RDaHVuayxcclxuICAgICAgICAgICAgbGFzdENodW5rLFxyXG4gICAgICAgICAgICBjdXJyZW50Q2h1bmssXHJcbiAgICAgICAgICAgIHByZXZQb3NpdGlvbnMsXHJcbiAgICAgICAgICAgIHBvc2l0aW9uSXNEaWZmZXJlbnQsXHJcbiAgICAgICAgICAgIHByZXZpb3VzRWxlbWVudHMsXHJcbiAgICAgICAgICAgIG1lbnVJc0RpZmZlcmVudCA9IHRydWUsXHJcbiAgICAgICAgICAgIGlzVmlydHVhbCA9IHRoYXQuaXNWaXJ0dWFsKCk7XHJcblxyXG4gICAgICAgIHRoYXQuc2VsZWN0cGlja2VyLnZpZXcuc2Nyb2xsVG9wID0gc2Nyb2xsVG9wO1xyXG5cclxuICAgICAgICBjaHVua1NpemUgPSBNYXRoLmNlaWwodGhhdC5zaXplSW5mby5tZW51SW5uZXJIZWlnaHQgLyB0aGF0LnNpemVJbmZvLmxpSGVpZ2h0ICogMS41KTsgLy8gbnVtYmVyIG9mIG9wdGlvbnMgaW4gYSBjaHVua1xyXG4gICAgICAgIGNodW5rQ291bnQgPSBNYXRoLnJvdW5kKHNpemUgLyBjaHVua1NpemUpIHx8IDE7IC8vIG51bWJlciBvZiBjaHVua3NcclxuXHJcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaHVua0NvdW50OyBpKyspIHtcclxuICAgICAgICAgIHZhciBlbmRPZkNodW5rID0gKGkgKyAxKSAqIGNodW5rU2l6ZTtcclxuXHJcbiAgICAgICAgICBpZiAoaSA9PT0gY2h1bmtDb3VudCAtIDEpIHtcclxuICAgICAgICAgICAgZW5kT2ZDaHVuayA9IHNpemU7XHJcbiAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgY2h1bmtzW2ldID0gW1xyXG4gICAgICAgICAgICAoaSkgKiBjaHVua1NpemUgKyAoIWkgPyAwIDogMSksXHJcbiAgICAgICAgICAgIGVuZE9mQ2h1bmtcclxuICAgICAgICAgIF07XHJcblxyXG4gICAgICAgICAgaWYgKCFzaXplKSBicmVhaztcclxuXHJcbiAgICAgICAgICBpZiAoY3VycmVudENodW5rID09PSB1bmRlZmluZWQgJiYgc2Nyb2xsVG9wIC0gMSA8PSB0aGF0LnNlbGVjdHBpY2tlci5jdXJyZW50LmRhdGFbZW5kT2ZDaHVuayAtIDFdLnBvc2l0aW9uIC0gdGhhdC5zaXplSW5mby5tZW51SW5uZXJIZWlnaHQpIHtcclxuICAgICAgICAgICAgY3VycmVudENodW5rID0gaTtcclxuICAgICAgICAgIH1cclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmIChjdXJyZW50Q2h1bmsgPT09IHVuZGVmaW5lZCkgY3VycmVudENodW5rID0gMDtcclxuXHJcbiAgICAgICAgcHJldlBvc2l0aW9ucyA9IFt0aGF0LnNlbGVjdHBpY2tlci52aWV3LnBvc2l0aW9uMCwgdGhhdC5zZWxlY3RwaWNrZXIudmlldy5wb3NpdGlvbjFdO1xyXG5cclxuICAgICAgICAvLyBhbHdheXMgZGlzcGxheSBwcmV2aW91cywgY3VycmVudCwgYW5kIG5leHQgY2h1bmtzXHJcbiAgICAgICAgZmlyc3RDaHVuayA9IE1hdGgubWF4KDAsIGN1cnJlbnRDaHVuayAtIDEpO1xyXG4gICAgICAgIGxhc3RDaHVuayA9IE1hdGgubWluKGNodW5rQ291bnQgLSAxLCBjdXJyZW50Q2h1bmsgKyAxKTtcclxuXHJcbiAgICAgICAgdGhhdC5zZWxlY3RwaWNrZXIudmlldy5wb3NpdGlvbjAgPSBpc1ZpcnR1YWwgPT09IGZhbHNlID8gMCA6IChNYXRoLm1heCgwLCBjaHVua3NbZmlyc3RDaHVua11bMF0pIHx8IDApO1xyXG4gICA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MsXHJcbiAgICAgICAgICAgICAgICB0b1Nhbml0aXplID0gW107XHJcblxyXG4gICAgICAgICAgICAvLyByZXBsYWNlIHRoZSBleGlzdGluZyBVTCB3aXRoIGFuIGVtcHR5IG9uZSAtIHRoaXMgaXMgZmFzdGVyIHRoYW4gJC5lbXB0eSgpXHJcbiAgICAgICAgICAgIG1lbnVJbm5lci5yZXBsYWNlQ2hpbGQoZW1wdHlNZW51LCBtZW51SW5uZXIuZmlyc3RDaGlsZCk7XHJcblxyXG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgdmlzaWJsZUVsZW1lbnRzTGVuID0gZWxlbWVudHMubGVuZ3RoOyBpIDwgdmlzaWJsZUVsZW1lbnRzTGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICB2YXIgZWxlbWVudCA9IGVsZW1lbnRzW2ldLFxyXG4gICAgICAgICAgICAgICAgICBlbFRleHQsXHJcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhO1xyXG5cclxuICAgICAgICAgICAgICBpZiAodGhhdC5vcHRpb25zLnNhbml0aXplKSB7XHJcbiAgICAgICAgICAgICAgICBlbFRleHQgPSBlbGVtZW50Lmxhc3RDaGlsZDtcclxuXHJcbiAgICAgICAgICAgICAgICBpZiAoZWxUZXh0KSB7XHJcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhID0gdGhhdC5zZWxlY3RwaWNrZXIuY3VycmVudC5kYXRhW2kgKyB0aGF0LnNlbGVjdHBpY2tlci52aWV3LnBvc2l0aW9uMF07XHJcblxyXG4gICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudERhdGEgJiYgZWxlbWVudERhdGEuY29udGVudCAmJiAhZWxlbWVudERhdGEuc2FuaXRpemVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdG9TYW5pdGl6ZS5wdXNoKGVsVGV4dCk7XHJcbiAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuc2FuaXRpemVkID0gdHJ1ZTtcclxuICAg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5tZW51SW5uZXJJbm5lcldpZHRoICsgJ3B4JztcclxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1lbnVJbm5lcklubmVyV2lkdGggPiB0aGF0LnNpemVJbmZvLm1lbnVJbm5lcklubmVyV2lkdGgpIHtcclxuICAgICAgICAgICAgICAgIC8vIHNldCB0byAwIHRvIGdldCBhY3R1YWwgd2lkdGggb2YgbWVudVxyXG4gICAgICAgICAgICAgICAgdGhhdC4kbWVudVswXS5zdHlsZS5taW5XaWR0aCA9IDA7XHJcblxyXG4gICAgICAgICAgICAgICAgdmFyIGFjdHVhbE1lbnVXaWR0aCA9IG1lbnVJbm5lci5maXJzdENoaWxkLm9mZnNldFdpZHRoO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmIChhY3R1YWxNZW51V2lkdGggPiB0aGF0LnNpemVJbmZvLm1lbnVJbm5lcklubmVyV2lkdGgpIHtcclxuICAgICAgICAgICAgICAgICAgdGhhdC5zaXplSW5mby5tZW51SW5uZXJJbm5lcldpZHRoID0gYWN0dWFsTWVudVdpZHRoO1xyXG4gICAgICAgICAgICAgICAgICBtZW51SW5uZXIuZmlyc3RDaGlsZC5zdHlsZS5taW5XaWR0aCA9IHRoYXQuc2l6ZUluZm8ubWVudUlubmVySW5uZXJXaWR0aCArICdweCc7XHJcbiAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgLy8gcmVzZXQgdG8gZGVmYXVsdCBDU1Mgc3R5bGluZ1xyXG4gICAgICAgICAgICAgICAgdGhhdC4kbWVudVswXS5zdHlsZS5taW5XaWR0aCA9ICcnO1xyXG4gICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgdGhhdC5wcmV2QWN0aXZlSW5kZXggPSB0aGF0LmFjdGl2ZUluZGV4O1xyXG5cclxuICAgICAgICBpZiAoIXRoYXQub3B0aW9ucy5saXZlU2VhcmNoKSB7XHJ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yXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgY29uZmlnID0gY29uZmlnIHx8IHt9O1xyXG4gICAgICAgIGNvbmZpZy50eXBlID0gJ2RpdmlkZXInO1xyXG5cclxuICAgICAgICBtYWluRWxlbWVudHMucHVzaChcclxuICAgICAgICAgIGdlbmVyYXRlT3B0aW9uLmxpKFxyXG4gICAgICAgICAgICBmYWxzZSxcclxuICAgICAgICAgICAgY2xhc3NOYW1lcy5ESVZJREVSLFxyXG4gICAgICAgICAgICAoY29uZmlnLm9wdElEID8gY29uZmlnLm9wdElEICsgJ2RpdicgOiB1bmRlZmluZWQpXHJcbiAgICAgICAgICApXHJcbiAgICAgICAgKTtcclxuXHJcbiAgICAgICAgbWFpbkRhdGEucHVzaChjb25maWcpO1xyXG4gICAgICB9XHJcblxyXG4gICAgICBmdW5jdGlvbiBhZGRPcHRpb24gKG9wdGlvbiwgY29uZmlnKSB7XHJcbiAgICAgICAgY29uZmlnID0gY29uZmlnIHx8IHt9O1xyXG5cclxuICAgICAgICBjb25maWcuZGl2aWRlciA9IG9wdGlvbi5nZXRBdHRyaWJ1dGUoJ2RhdGEtZGl2aWRlcicpID09PSAndHJ1ZSc7XHJcblxyXG4gICAgICAgIGlmIChjb25maWcuZGl2aWRlcikge1xyXG4gICAgICAgICAgYWRkRGl2aWRlcih7XHJcbiAgICAgICAgICAgIG9wdElEOiBjb25maWcub3B0SURcclxuICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICB2YXIgbGlJbmRleCA9IG1haW5EYXRhLmxlbmd0aCxcclxuICAgICAgICAgICAgICBjc3NUZXh0ID0gb3B0aW9uLnN0eWxlLmNzc1RleHQsXHJcbiAgICAgICAgICAgICAgaW5saW5lU3R5bGUgPSBjc3NUZXh0ID8gaHRtbEVzY2FwZShjc3NUZXh0KSA6ICcnLFxyXG4gICAgICAgICAgICAgIG9wdGlvbkNsYXNzID0gKG9wdGlvbi5jbGFzc05hbWUgfHwgJycpICsgKGNvbmZpZy5vcHRncm91cENsYXNzIHx8ICcnKTtcclxuXHJcbiAgICAgICAgICBpZiAoY29uZmlnLm9wdElEKSBvcHRpb25DbGFzcyA9ICdvcHQgJyArIG9wdGlvbkNsYXNzO1xyXG5cclxuICAgICAgICAgIGNvbmZpZy50ZXh0ID0gb3B0aW9uLnRleHRDb250ZW50O1xyXG5cclxuICAgICAgICAgIGNvbmZpZy5jb250ZW50ID0gb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS1jb250ZW50Jyk7XHJcbiAgICAgICAgICBjb25maWcudG9rZW5zID0gb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS10b2tlbnMnKTtcclxuICAgICAgICAgIGNvbmZpZy5zdWJ0ZXh0ID0gb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS1zdWJ0ZXh0Jyk7XHJcbiAgICAgICAgICBjb25maWcuaWNvbiA9IG9wdGlvbi5nZXRBdHRyaWJ1dGUoJ2RhdGEtaWNvbicpO1xyXG4gICAgICAgICAgY29uZmlnLmljb25CYXNlID0gaWNvbkJhc2U7XHJcblxyXG4gICAgICAgICAgdmFyIHRleHRFbGVtZW50ID0gZ2VuZXJhdGVPcHRpb24udGV4dChjb25maWcpO1xyXG4gICAgICAgICAgdmFyIGxpRWxlbWVudCA9IGdlbmVyYXRlT3B0aW9uLmxpKFxyXG4gICAgICAgICAgICBnZW5lcmF0ZU9wdGlvbi5hKFxyXG4gICAgICAgICAgICAgIHRleHRFbGVtZW50LFxyXG4gICAgICAgICAgICAgIG9wdGlvbkNsYXNzLFxyXG4gICAgICAgICAgICAgIGlubGluZVN0eWxlXHJcbiAgICAgICAgICAgICksXHJcbiAgICAgICAgICAgICcnLFxyXG4gICAgICAgICAgICBjb25maWcub3B0SURcclxuICAgICAgICAgICk7XHJcblxyXG4gICAgICAgICAgaWYgKGxpRWxlbWVudC5maXJzdENoaWxkKSB7XHJcbiAgICAgICAgICAgIGxpRWxlbWVudC5maXJzdENoaWxkLmlkID0gdGhhdC5zZWxlY3RJZCArICctJyArIGxpSW5kZXg7XHJcbiAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgbWFpbkVsZW1lbnRzLnB1c2gobGlFbGVtZW50KTtcclxuXHJcbiAgICAgICAgICBvcHRpb24ubGlJbmRleCA9IGxpSW5kZXg7XHJcblxyXG4gICAgICAgICAgY29uZmlnLmRpc3BsYXkgPSBjb25maWcuY29udGVudCB8fCBjb25maWcudGV4dDtcclxuICAgICAgICAgIGNvbmZpZy50eXBlID0gJ29wdGlvbic7XHJcbiAgICAgICAgICBjb25maWcuaW5kZXggPSBsaUluZGV4O1xyXG4gICAgICAgICAgY29uZmlnLm9wdGlvbiA9IG9wdGlvbjtcclxuICAgICAgICAgIGNvbmZpZy5kaXNhYmxlZCA9IGNvbmZpZy5kaXNhYmxlZCB8fCBvcHRpb24uZGlzYWJsZWQ7XHJcblxyXG4gICAgICAgICAgbWFpbkRhdGEucHVzaChjb25maWcpO1xyXG5cclxuICAgICAgICAgIHZhciBjb21iaW5lZExlbmd0aCA9IDA7XHJcblxyXG4gICAgICAgICAgLy8gY291bnQgdGhlIG51bWJlciBvZiBjaGFyYWN0ZXJzIGluIHRoZSBvcHRpb24gLSBub3QgcGVyZmVjdCwgYnV0IHNob3VsZCB3b3JrIGluIG1vc3QgY2FzZXNcclxuICAgICAgICAgIGlmIChjb25maWcuZGlzcGxheSkgY29tYmluZWRMZW5ndGggKz0gY29uZmlnLmRpc3BsYXkubGVuZ3RoO1xyXG4gICAgICAgICAgaWYgKGNvbmZpZy5zdWJ0ZXh0KSBjb21iaW5lZExlbmd0aCArPSBjb25maWcuc3VidGV4dC5sZW5ndGg7XHJcbiAgICAgICAgICAvLyBpZiB0aGVyZSBpcyBhbiBpY29uLCBlbnN1cmUgdGhpcyBvcHRpb24ncyB3aWR0aCBpcyBjaGVja2VkXHJcbiAgICAgICAgICBpZiAoY29uZmlnLmljb24pIGNvbWJpbmVkTGVuZ3RoICs9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4gICAgICAgIGZvciAodmFyIGogPSAwLCBsZW4gPSBvcHRpb25zLmxlbmd0aDsgaiA8IGxlbjsgaisrKSB7XHJcbiAgICAgICAgICB2YXIgb3B0aW9uID0gb3B0aW9uc1tqXTtcclxuXHJcbiAgICAgICAgICBpZiAoaiA9PT0gMCkge1xyXG4gICAgICAgICAgICBoZWFkZXJJbmRleCA9IG1haW5EYXRhLmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgIGxhc3RJbmRleCA9IGhlYWRlckluZGV4ICsgbGVuO1xyXG4gICAgICAgICAgfVxyXG5cclxuICAgICAgICAgIGFkZE9wdGlvbihvcHRpb24sIHtcclxuICAgICAgICAgICAgaGVhZGVySW5kZXg6IGhlYWRlckluZGV4LFxyXG4gICAgICAgICAgICBsYXN0SW5kZXg6IGxhc3RJbmRleCxcclxuICAgICAgICAgICAgb3B0SUQ6IG9wdElELFxyXG4gICAgICAgICAgICBvcHRncm91cENsYXNzOiBvcHRncm91cENsYXNzLFxyXG4gICAgICAgICAgICBkaXNhYmxlZDogb3B0Z3JvdXAuZGlzYWJsZWRcclxuICAgICAgICAgIH0pO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYgKG5leHQpIHtcclxuICAgICAgICAgIGFkZERpdmlkZXIoeyBvcHRJRDogb3B0SUQgfSk7XHJcbiAgICAgICAgfVxyXG4gICAgICB9XHJcblxyXG4gICAgICBmb3IgKHZhciBsZW4gPSBzZWxlY3RPcHRpb25zLmxlbmd0aDsgc3RhcnRJbmRleCA8IGxlbjsgc3RhcnRJbmRleCsrKSB7XHJcbiAgICAgICAgdmFyIGl0ZW0gPSBzZWxlY3RPcHRpb25zW3N0YXJ0SW5kZXhdO1xyXG5cclxuICAgICAgICBpZiAoaXRlbS50YWdOYW1lICE9PSAnT1BUR1JPVVAnKSB7XHJcbiAgICAgICAgICBhZGRPcHRpb24oaXRlbSwge30pO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICBhZGRPc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dW50KSB7XHJcbiAgICAgICAgICBjb3VudE1heCA9IHRoaXMub3B0aW9ucy5zZWxlY3RlZFRleHRGb3JtYXQuc3BsaXQoJz4nKTtcclxuICAgICAgICAgIHNob3dDb3VudCA9IChjb3VudE1heC5sZW5ndGggPiAxICYmIHNlbGVjdGVkQ291bnQgPiBjb3VudE1heFsxXSkgfHwgKGNvdW50TWF4Lmxlbmd0aCA9PT0gMSAmJiBzZWxlY3RlZENvdW50ID49IDIpO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgLy8gb25seSBsb29wIHRocm91Z2ggYWxsIHNlbGVjdGVkIG9wdGlvbnMgaWYgdGhlIGNvdW50IHdvbid0IGJlIHNob3duXHJcbiAgICAgICAgaWYgKHNob3dDb3VudCA9PT0gZmFsc2UpIHtcclxuICAgICAgICAgIGZvciAodmFyIHNlbGVjdGVkSW5kZXggPSAwOyBzZWxlY3RlZEluZGV4IDwgc2VsZWN0ZWRDb3VudDsgc2VsZWN0ZWRJbmRleCsrKSB7XHJcbiAgICAgICAgICAgIGlmIChzZWxlY3RlZEluZGV4IDwgNTApIHtcclxuICAgICAgICAgICAgICB2YXIgb3B0aW9uID0gc2VsZWN0ZWRPcHRpb25zW3NlbGVjdGVkSW5kZXhdLFxyXG4gICAgICAgICAgICAgICAgICB0aXRsZU9wdGlvbnMgPSB7fSxcclxuICAgICAgICAgICAgICAgICAgdGhpc0RhdGEgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS1jb250ZW50JyksXHJcbiAgICAgICAgICAgICAgICAgICAgc3VidGV4dDogb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS1zdWJ0ZXh0JyksXHJcbiAgICAgICAgICAgICAgICAgICAgaWNvbjogb3B0aW9uLmdldEF0dHJpYnV0ZSgnZGF0YS1pY29uJylcclxuICAgICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgICAgaWYgKHRoaXMubXVsdGlwbGUgJiYgc2VsZWN0ZWRJbmRleCA+IDApIHtcclxuICAgICAgICAgICAgICAgIHRpdGxlRnJhZ21lbnQuYXBwZW5kQ2hpbGQobXVsdGlwbGVTZXBhcmF0b3IuY2xvbmVOb2RlKGZhbHNlKSk7XHJcbiAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICBpZiAob3B0aW9uLnRpdGxlKSB7XHJcbiAgICAgICAgICAgICAgICB0aXRsZU9wdGlvbnMudGV4dCA9IG9wdGlvbi50aXRsZTtcclxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXNEYXRhLmNvbnRlbnQgJiYgdGhhdC5vcHRpb25zLnNob3dDb250ZW50KSB7XHJcbiAgICAgICAgICAgICAgICB0aXRsZU9wdGlvbnMuY29udGVudCA9IHRoaXNEYXRhLmNvbnRlbnQudG9TdHJpbmcoKTtcclxuICAgICAgICAgICAgICAgIGhhc0NvbnRlbnQgPSB0cnVlO1xyXG4gICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAodGhhdC5vcHRpb25zLnNob3dJY29uKSB7XHJcbiAgICAgICAgICAgICAgICAgIHRpdGxlT3B0aW9ucy5pY29uID0gdGhpc0RhdGEuaWNvbjtcclxuICAgICAgICAgICAgICAgICAgdGl0bGVPcHRpb25zLmljb25CYXNlID0gdGhpcy5vcHRpb25zLmljb25CYXNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKHRoYXQub3B0aW9ucy5zaG93U3VidGV4dCAmJiAhdGhhdC5tdWx0aXBsZSAmJiB0aGlzRGF0YS5zdWJ0ZXh0KSB0aXRsZU9wdGlvbnMuc3VidGV4dCA9ICcgJyArIHRoaXNEYXRhLnN1YnRleHQ7XHJcbiAgICAgICAgICAgICAgICB0aXRsZU9wdGlvbnMudGV4dCA9IG9wdGlvbi50ZXh0Q29udGVudC50cmltKCk7XHJcbiAgICAgICAgICAg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XG4gICAgICAgICAgICAgICAgKTtcclxuXHJcbiAgICAgICAgICAgIHRoYXQuJGJzQ29udGFpbmVyLmFkZENsYXNzKCRlbGVtZW50LmF0dHIoJ2NsYXNzJykucmVwbGFjZSgvZm9ybS1jb250cm9sfGZpdC13aWR0aC9naSwgJycpKS50b2dnbGVDbGFzcyhjbGFzc05hbWVzLkRST1BVUCwgJGVsZW1lbnQuaGFzQ2xhc3MoY2xhc3NOYW1lcy5EUk9QVVApKTtcclxuICAgICAgICAgICAgcG9zID0gJGVsZW1lbnQub2Zmc2V0KCk7XHJcblxyXG4gICAgICAgICAgICBpZiAoISRjb250YWluZXIuaXMoJ2JvZHknKSkge1xyXG4gICAgICAgICAgICAgIGNvbnRhaW5lclBvcyA9ICRjb250YWluZXIub2Zmc2V0KCk7XHJcbiAgICAgICAgICAgICAgY29udGFpbmVyUG9zLnRvcCArPSBwYXJzZUludCgkY29udGFpbmVyLmNzcygnYm9yZGVyVG9wV2lkdGgnKSkgLSAkY29udGFpbmVyLnNjcm9sbFRvcCgpO1xyXG4gICAgICAgICAgICAgIGNvbnRhaW5lclBvcy5sZWZ0ICs9IHBhcnNlSW50KCRjb250YWluZXIuY3NzKCdib3JkZXJMZWZ0V2lkdGgnKSkgLSAkY29udGFpbmVyLnNjcm9sbExlZnQoKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICBjb250YWluZXJQb3MgPSB7IHRvcDogMCwgbGVmdDogMCB9O1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBhY3R1YWxIZWlnaHQgPSAkZWxlbWVudC5oYXNDbGFzcyhjbGFzc05hbWVzLkRST1BVUCkgPyAwIDogJGVsZW1lbnRbMF0ub2Zmc2V0SGVpZ2h0O1xyXG5cclxuICAgICAgICAgICAgLy8gQm9vdHN0cmFwIDQrIHVzZXMgUG9wcGVyIGZvciBtZW51IHBvc2l0aW9uaW5nXHJcbiAgICAgICAgICAgIGlmICh2ZXJzaW9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b25zIDwgZ2V0U2VsZWN0ZWRPcHRpb25zKGVsZW1lbnQpLmxlbmd0aCxcclxuICAgICAgICAgICAgICAgICAgbWF4UmVhY2hlZEdycCA9IG1heE9wdGlvbnNHcnAgPCAkb3B0Z3JvdXAuZmluZCgnb3B0aW9uOnNlbGVjdGVkJykubGVuZ3RoO1xyXG5cclxuICAgICAgICAgICAgICBpZiAoKG1heE9wdGlvbnMgJiYgbWF4UmVhY2hlZCkgfHwgKG1heE9wdGlvbnNHcnAgJiYgbWF4UmVhY2hlZEdycCkpIHtcclxuICAgICAgICAgICAgICAgIGlmIChtYXhPcHRpb25zICYmIG1heE9wdGlvbnMgPT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICBlbGVtZW50LnNlbGVjdGVkSW5kZXggPSAtMTtcclxuICAgICAgICAgICAgICAgICAgb3B0aW9uLnNlbGVjdGVkID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgdGhhdC5zZXRPcHRpb25TdGF0dXModHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1heE9wdGlvbnNHcnAgJiYgbWF4T3B0aW9uc0dycCA9PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgJG9wdGdyb3VwT3B0aW9ucy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBfb3B0aW9uID0gJG9wdGdyb3VwT3B0aW9uc1tpXTtcclxuICAgICAgICAgICAgICAgICAgICBfb3B0aW9uLnNlbGVjdGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhhdC5zZXRTZWxlY3RlZChfb3B0aW9uLmxpSW5kZXgsIGZhbHNlKTtcclxuICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgb3B0aW9uLnNlbGVjdGVkID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgdGhhdC5zZXRTZWxlY3RlZChjb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DFdKTtcclxuICAgICAgICAgICAgICAgICAgICBtYXhUeHRHcnAgPSBtYXhUeHRHcnAucmVwbGFjZSgne3Zhcn0nLCBtYXhPcHRpb25zQXJyWzJdW21heE9wdGlvbnNHcnAgPiAxID8gMCA6IDFdKTtcclxuICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgb3B0aW9uLnNlbGVjdGVkID0gZmFsc2U7XHJcblxyXG4gICAgICAgICAgICAgICAgICB0aGF0LiRtZW51LmFwcGVuZCgkbm90aWZ5KTtcclxuXHJcbiAgICAgICAgICAgICAgICAgIGlmIChtYXhPcHRpb25zICYmIG1heFJlYWNoZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAkbm90aWZ5LmFwcGVuZCgkKCc8ZGl2PicgKyBtYXhUeHQgKyAnPC9kaXY+JykpO1xyXG4gICAgICAgICAgICAgICAgICAgIHRyaWdnZXJDaGFuZ2UgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB0aGF0LiRlbGVtZW50LnRyaWdnZXIoJ21heFJlYWNoZWQnICsgRVZFTlRfS0VZKTtcclxuICAgICAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICAgICAgaWYgKG1heE9wdGlvbnNHcnAgJiYgbWF4UmVhY2hlZEdycCkge1xyXG4gICAgICAgICAgICAgICAgICAgICRub3RpZnkuYXBwZW5kKCQoJzxkaXY+JyArIG1heFR4dEdycCArICc8L2Rpdj4nKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgdHJpZ2dlckNoYW5nZSA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIHRoYXQuJGVsZW1lbnQudHJpZ2dlcignbWF4UmVhY2hlZEdycCcgKyBFVkVOVF9LRVkpO1xyXG4gICAgICAgICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICB0aGF0LnNldF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ubmVyLmZpbmQoJy5zZWxlY3RlZCcpO1xyXG5cclxuICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdGhhdC5zZWxlY3RwaWNrZXIubWFpbi5kYXRhLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgIHZhciBsaSA9IHRoYXQuc2VsZWN0cGlja2VyLm1haW4uZGF0YVtpXTtcclxuXHJcbiAgICAgICAgICAgIGlmICghY2FjaGVbaV0pIHtcclxuICAgICAgICAgICAgICBjYWNoZVtpXSA9IHN0cmluZ1NlYXJjaChsaSwgcSwgc2VhcmNoU3R5bGUsIG5vcm1hbGl6ZVNlYXJjaCk7XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChjYWNoZVtpXSAmJiBsaS5oZWFkZXJJbmRleCAhPT0gdW5kZWZpbmVkICYmIGNhY2hlQXJyLmluZGV4T2YobGkuaGVhZGVySW5kZXgpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgIGlmIChsaS5oZWFkZXJJbmRleCA+IDApIHtcclxuICAgICAgICAgICAgICAgIGNhY2hlW2xpLmhlYWRlckluZGV4IC0gMV0gPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgY2FjaGVBcnIucHVzaChsaS5oZWFkZXJJbmRleCAtIDEpO1xyXG4gICAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgICAgY2FjaGVbbGkuaGVhZGVySW5kZXhdID0gdHJ1ZTtcclxuICAgICAgICAgICAgICBjYWNoZUFyci5wdXNoKGxpLmhlYWRlckluZGV4KTtcclxuXHJcbiAgICAgICAgICAgICAgY2FjaGVbbGkubGFzdEluZGV4ICsgMV0gPSB0cnVlO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoY2FjaGVbaV0gJiYgbGkudHlwZSAhPT0gJ29wdGdyb3VwLWxhYmVsJykgY2FjaGVBcnIucHVzaChpKTtcclxuICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICBmb3IgKHZhciBpID0gMCwgY2FjaGVMZW4gPSBjYWNoZUFyci5sZW5ndGg7IGkgPCBjYWNoZUxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgIHZhciBpbmRleCA9IGNhY2hlQXJyW2ldLFxyXG4gICAgICAgICAgICAgICAgcHJldkluZGV4ID0gY2FjaGVBcnJbaSAtIDFdLFxyXG4gICAgICAgICAgICAgICAgbGkgPSB0aGF0LnNlbGVjdHBpY2tlci5tYWluLmRhdGFbaW5kZXhdLFxyXG4gICAgICAgICAgICAgICAgbGlQcmV2ID0gdGhhdC5zZWxlY3RwaWNrZXIubWFpbi5kYXRhW3ByZXZJbmRleF07XHJcblxyXG4gICAgICAgICAgICBpZiAobGkudHlwZSAhPT0gJ2RpdmlkZXInIHx8IChsaS50eXBlID09PSAnZGl2aWRlcicgJiYgbGlQcmV2ICYmIGxpUHJldi50eXBlICE9PSAnZGl2aWRlcicgJiYgY2FjaGVMZW4gLSAxICE9PSBpKSkge1xyXG4gICAgICAgICAgICAgIHRoYXQuc2VsZWN0cGlja2VyLnNlYXJjaC5kYXRhLnB1c2gobGkpO1xyXG4gICAgICAgICAgICAgIHNlYXJjaE1hdGNoLnB1c2godGhhdC5zZWxlY3RwaWNrZXIubWFpbi5lbGVtZW50c1tpbmRleF0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgdGhhdC5hY3RpdmVJbmRleCA9IHVuZGVmaW5lZDtcclxuICAgICAgICAgIHRoYXQubm9TY3JvbGwgPSB0cnVlO1xyXG4gICAgICAgICAgdGhhdC4kbWVudUlubmVyLnNjcm9sbFRvcCgwKTtcclxuICAgICAgICAgIHRoYXQuc2VsZWN0cGlja2VyLnNlYXJjaC5lbGVtZW50cyA9IHNlYXJjaE1hdGNoO1xyXG4gICAgICAgICAgdGhhdC5jcmVhdGVWaWV3KHRydWUpO1xyXG5cclxuICAgICAgICAgIGlmICghc2VhcmNoTWF0Y2gubGV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biAgICAgICAgICBhY3RpdmVMaSxcclxuICAgICAgICAgIG9mZnNldCxcclxuICAgICAgICAgIHVwZGF0ZVNjcm9sbCA9IGZhbHNlLFxyXG4gICAgICAgICAgZG93bk9uVGFiID0gZS53aGljaCA9PT0ga2V5Q29kZXMuVEFCICYmICFpc1RvZ2dsZSAmJiAhdGhhdC5vcHRpb25zLnNlbGVjdE9uVGFiLFxyXG4gICAgICAgICAgaXNBcnJvd0tleSA9IFJFR0VYUF9BUlJPVy50ZXN0KGUud2hpY2gpIHx8IGRvd25PblRhYixcclxuICAgICAgICAgIHNjcm9sbFRvcCA9IHRoYXQuJG1lbnVJbm5lclswXS5zY3JvbGxUb3AsXHJcbiAgICAgICAgICBpc1ZpcnR1YWwgPSB0aGF0LmlzVmlydHVhbCgpLFxyXG4gICAgICAgICAgcG9zaXRpb24wID0gaXNWaXJ0dWFsID09PSB0cnVlID8gdGhhdC5zZWxlY3RwaWNrZXIudmlldy5wb3NpdGlvbjAgOiAwO1xyXG5cclxuICAgICAgLy8gZG8gbm90aGluZyBpZiBhIGZ1bmN0aW9uIGtleSBpcyBwcmVzc2VkXHJcbiAgICAgIGlmIChlLndoaWNoID49IDExMiAmJiBlLndoaWNoIDw9IDEyMykgcmV0dXJuO1xyXG5cclxuICAgICAgaXNBY3RpdmUgPSB0aGF0LiRuZXdFbGVtZW50Lmhhc0NsYXNzKGNsYXNzTmFtZXMuU0hPVyk7XHJcblxyXG4gICAgICBpZiAoXHJcbiAgICAgICAgIWlzQWN0aXZlICYmXHJcbiAgICAgICAgKFxyXG4gICAgICAgICAgaXNBcnJvd0tleSB8fFxyXG4gICAgICAgICAgKGUud2hpY2ggPj0gNDggJiYgZS53aGljaCA8PSA1NykgfHxcclxuICAgICAgICAgIChlLndoaWNoID49IDk2ICYmIGUud2hpY2ggPD0gMTA1KSB8fFxyXG4gICAgICAgICAgKGUud2hpY2ggPj0gNjUgJiYgZS53aGljaCA8PSA5MClcclxuICAgICAgICApXHJcbiAgICAgICkge1xyXG4gICAgICAgIHRoYXQuJGJ1dHRvbi50cmlnZ2VyKCdjbGljay5icy5kcm9wZG93bi5kYXRhLWFwaScpO1xyXG5cclxuICAgICAgICBpZiAodGhhdC5vcHRpb25zLmxpdmVTZWFyY2gpIHtcclxuICAgICAgICAgIHRoYXQuJHNlYXJjaGJveC50cmlnZ2VyKCdmb2N1cycpO1xyXG4gICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG5cclxuICAgICAgaWYgKGUud2hpY2ggPT09IGtleUNvZGVzLkVTQ0FQRSAmJiBpc0FjdGl2ZSkge1xyXG4gICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICB0aGF0LiRidXR0b24udHJpZ2dlcignY2xpY2suYnMuZHJvcGRvd24uZGF0YS1hcGknKS50cmlnZ2VyKCdmb2N1cycpO1xyXG4gICAgICB9XHJcblxyXG4gICAgICBpZiAoaXNBcnJvd0tleSkgeyAvLyBpZiB1cCBvciBkb3duXHJcbiAgICAgICAgaWYgKCEkaXRlbXMubGVuZ3RoKSByZXR1cm47XHJcblxyXG4gICAgICAgIGxpQWN0aXZlID0gdGhhdC5zZWxlY3RwaWNrZXIubWFpbi5lbGVtZW50c1t0aGF0LmFjdGl2ZUluZGV4XTtcclxuICAgICAgICBpbmRleCA9IGxpQWN0aXZlID8gQXJyYXkucHJvdG90eXBlLmluZGV4T2YuY2FsbChsaUFjdGl2ZS5wYXJlbnRFbGVtZW50LmNoaWxkcmVuLCBsaUFjdGl2ZSkgOiAtMTtcclxuXHJcbiAgICAgICAgaWYgKGluZGV4ICE9PSAtMSkge1xyXG4gICAgICAgICAgdGhhdC5kZWZvY3VzSXRlbShsaUFjdGl2ZSk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZiAoZS53aGljaCA9PT0ga2V5Q29kZXMuQVJST1dfVVApIHsgLy8gdXBcclxuICAgICAgICAgIGlmIChpbmRleCAhPT0gLTEpIGluZGV4LS07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ZScpICsgJ1wiXTpjaGVja2VkJykubGVuZ3RoIDpcbiAgICAgICAgICAgJGVsLmlzKCdzZWxlY3RbbXVsdGlwbGVdJykgID8gKCRlbC52YWwoKSB8fCBbXSkubGVuZ3RoICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRlbC52YWwoKVxuICB9XG5cbiAgdmFyIFZhbGlkYXRvciA9IGZ1bmN0aW9uIChlbGVtZW50LCBvcHRpb25zKSB7XG4gICAgdGhpcy5vcHRpb25zICAgID0gb3B0aW9uc1xuICAgIHRoaXMudmFsaWRhdG9ycyA9ICQuZXh0ZW5kKHt9LCBWYWxpZGF0b3IuVkFMSURBVE9SUywgb3B0aW9ucy5jdXN0b20pXG4gICAgdGhpcy4kZWxlbWVudCAgID0gJChlbGVtZW50KVxuICAgIHRoaXMuJGJ0biAgICAgICA9ICQoJ2J1dHRvblt0eXBlPVwic3VibWl0XCJdLCBpbnB1dFt0eXBlPVwic3VibWl0XCJdJylcbiAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoJ1tmb3JtPVwiJyArIHRoaXMuJGVsZW1lbnQuYXR0cignaWQnKSArICdcIl0nKVxuICAgICAgICAgICAgICAgICAgICAgICAgLmFkZCh0aGlzLiRlbGVtZW50LmZpbmQoJ2lucHV0W3R5cGU9XCJzdWJtaXRcIl0sIGJ1dHRvblt0eXBlPVwic3VibWl0XCJdJykpXG5cbiAgICB0aGlzLnVwZGF0ZSgpXG5cbiAgICB0aGlzLiRlbGVtZW50Lm9uKCdpbnB1dC5icy52YWxpZGF0b3IgY2hhbmdlLmJzLnZhbGlkYXRvciBmb2N1c291dC5icy52YWxpZGF0b3InLCAkLnByb3h5KHRoaXMub25JbnB1dCwgdGhpcykpXG4gICAgdGhpcy4kZWxlbWVudC5vbignc3VibWl0LmJzLnZhbGlkYXRvcicsICQucHJveHkodGhpcy5vblN1Ym1pdCwgdGhpcykpXG4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AgICAgICBzdG9wRXZlbnQ6IGZ1bmN0aW9uIChlKSB7XHJcbiAgICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCk7XHJcbiAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGdldEZpbGVOYW1lOiBmdW5jdGlvbiAoZmlsZSkge1xyXG4gICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBmaWxlLmZpbGVOYW1lICovXHJcbiAgICAgICAgICAgIHJldHVybiBmaWxlID8gKGZpbGUuZmlsZU5hbWUgfHwgZmlsZS5uYW1lIHx8ICcnKSA6ICcnOyAvLyBzb21lIGNvbmZ1c2lvbiBpbiBkaWZmZXJlbnQgdmVyc2lvbnMgb2YgRmlyZWZveFxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY3JlYXRlT2JqZWN0VVJMOiBmdW5jdGlvbiAoZGF0YSkge1xyXG4gICAgICAgICAgICBpZiAoJGgub2JqVXJsICYmICRoLm9ialVybC5jcmVhdGVPYmplY3RVUkwgJiYgZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuICRoLm9ialVybC5jcmVhdGVPYmplY3RVUkwoZGF0YSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuICcnO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgcmV2b2tlT2JqZWN0VVJMOiBmdW5jdGlvbiAoZGF0YSkge1xyXG4gICAgICAgICAgICBpZiAoJGgub2JqVXJsICYmICRoLm9ialVybC5yZXZva2VPYmplY3RVUkwgJiYgZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgJGgub2JqVXJsLnJldm9rZU9iamVjdFVSTChkYXRhKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY29tcGFyZTogZnVuY3Rpb24gKGlucHV0LCBzdHIsIGV4YWN0KSB7XHJcbiAgICAgICAgICAgIHJldHVybiBpbnB1dCAhPT0gdW5kZWZpbmVkICYmIChleGFjdCA/IGlucHV0ID09PSBzdHIgOiBpbnB1dC5tYXRjaChzdHIpKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGlzSUU6IGZ1bmN0aW9uICh2ZXIpIHtcclxuICAgICAgICAgICAgdmFyIGRpdiwgc3RhdHVzO1xyXG4gICAgICAgICAgICAvLyBjaGVjayBmb3IgSUUgdmVyc2lvbnMgPCAxMVxyXG4gICAgICAgICAgICBpZiAobmF2aWdhdG9yLmFwcE5hbWUgIT09ICdNaWNyb3NvZnQgSW50ZXJuZXQgRXhwbG9yZXInKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHZlciA9PT0gMTApIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVnRXhwKCdtc2llXFxcXHMnICsgdmVyLCAnaScpLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7XHJcbiAgICAgICAgICAgIGRpdi5pbm5lckhUTUwgPSAnPCEtLVtpZiBJRSAnICsgdmVyICsgJ10+IDxpPjwvaT4gPCFbZW5kaWZdLS0+JztcclxuICAgICAgICAgICAgc3RhdHVzID0gZGl2LmdldEVsZW1lbnRzQnlUYWdOYW1lKCdpJykubGVuZ3RoO1xyXG4gICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGRpdik7XHJcbiAgICAgICAgICAgIGRpdi5wYXJlbnROb2RlLnJlbW92ZUNoaWxkKGRpdik7XHJcbiAgICAgICAgICAgIHJldHVybiBzdGF0dXM7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBjYW5Bc3NpZ25GaWxlc1RvSW5wdXQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIGlucHV0ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaW5wdXQnKTtcclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIGlucHV0LnR5cGUgPSAnZmlsZSc7XHJcbiAgICAgICAgICAgICAgICBpbnB1dC5maWxlcyA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIGdldERyYWdEcm9wRm9sZGVyczogZnVuY3Rpb24gKGl0ZW1zKSB7XHJcbiAgICAgICAgICAgIHZhciBpLCBpdGVtLCBsZW4gPSBpdGVtcyA/IGl0ZW1zLmxlbmd0aCA6IDAsIGZvbGRlcnMgPSAwO1xyXG4gICAgICAgICAgICBpZiAobGVuID4gMCAmJiBpdGVtc1swXS53ZWJraXRHZXRBc0VudHJ5KCkpIHtcclxuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgIGl0ZW0gPSBpdGVtc1tpXS53ZWJraXRHZXRBc0VudHJ5KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0gJiYgaXRlbS5pc0RpcmVjdG9yeSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb2xkZXJzKys7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiBmb2xkZXJzO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaW5pdE1vZGFsOiBmdW5jdGlvbiAoJG1vZGFsKSB7XHJcbiAgICAgICAgICAgIHZhciAkYm9keSA9ICQoJ2JvZHknKTtcclxuICAgICAgICAgICAgaWYgKCRib2R5Lmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgJG1vZGFsLmFwcGVuZFRvKCRib2R5KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaXNFbXB0eTogZnVuY3Rpb24gKHZhbHVlLCB0cmltKSB7XHJcbiAgICAgICAgICAgIHJldHVybiB2YWx1ZSA9PT0gdW5kZWZpbmVkIHx8IHZhbHVlID09PSBudWxsIHx8IHZhbHVlLmxlbmd0aCA9PT0gMCB8fCAodHJpbSAmJiAkLnRyaW0odmFsdWUpID09PSAnJyk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBpc0FycmF5OiBmdW5jdGlvbiAoYSkge1xyXG4gICAgICAgICAgICByZXR1cm4gQXJyYXkuaXNBcnJheShhKSB8fCBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwoYSkgPT09ICdbb2JqZWN0IEFycmF5XSc7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBpZlNldDogZnVuY3Rpb24gKG5lZWRsZSwgaGF5c3RhY2ssIGRlZikge1xyXG4gICAgICAgICAgICBkZWYgPSBkZWYgfHwgJyc7XHJcbiAgICAgICAgICAgIHJldHVybiAoaGF5c3RhY2sgJiYgdHlwZW9mIGhheXN0YWNrID09PSAnb2JqZWN0JyAmJiBuZWVkbGUgaW4gaGF5c3RhY2spID8gaGF5c3RhY2tbbmVlZGxlXSA6IGRlZjtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGNsZWFuQXJyYXk6IGZ1bmN0aW9uIChhcnIpIHtcclxuICAgICAgICAgICAgaWYgKCEoYXJyIGluc3RhbmNlb2YgQXJyYXkpKSB7XHJcbiAgICAgICAgICAgICAgICBhcnIgPSBbXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gYXJyLmZpbHRlcihmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIChlICE9PSB1bmRlZmluZWQgJiYgZSAhPT0gbnVsbCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgc3BsaWNlQXJyYXk6IGZ1bmN0aW9uIChhcnIsIGluZGV4LCByZXZlcnNlT3JkZXIpIHtcclxuICAgICAgICAgICAgdmFyIGksIGogPSAwLCBvdXQgPSBbXSwgbmV3QXJyO1xyXG4gICAgICAgICAgICBpZiAoIShhcnIgaW5zdGFuY2VvZiBBcnJheSkpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBbXTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBuZXdBcnIgPSAkLmV4dGVuZCh0cnVlLCBbXSwgYXJyKTtcclxuICAgICAgICAgICAgaWYgKHJldmVyc2VPcmRlcikge1xyXG4gICAgICAgICAgICAgICAgbmV3QXJyLnJldmVyc2UoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbmV3QXJyLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaSAhPT0gaW5kZXgpIHtcclxuICAgICAgICAgICAgICAgICAgICBvdXRbal0gPSBuZXdBcnJbaV07XHJcbiAgICAgICAgICAgICAgICAgICAgaisrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChyZXZlcnNlT3JkZXIpIHtcclxuICAgICAgICAgICAgICAgIG91dC5yZXZlcnNlKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIG91dDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGdldE51bTogZnVuY3Rpb24gKG51bSwgZGVmKSB7XHJcbiAgICAgICAgICAgIGRlZiA9IGRlZiB8fCAwO1xyXG4gICAgICAgICAgICBpZiAodHlwZW9mIG51bSA9PT0gJ251bWJlcicpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBudW07XHJcbiAgICAgICAgICAgIH1ccl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1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIHJldHVybiAhIXdpbmRvdy5CbG9iICYmIEJvb2xlYW4obmV3IEJsb2IoKSk7XHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaGFzQXJyYXlCdWZmZXJWaWV3U3VwcG9ydDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBCbG9iKFtuZXcgVWludDhBcnJheSgxMDApXSkuc2l6ZSA9PT0gMTAwO1xyXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIGRhdGFVUkkyQmxvYjogZnVuY3Rpb24gKGRhdGFVUkkpIHtcclxuICAgICAgICAgICAgLy9ub2luc3BlY3Rpb24gSlNVbnJlc29sdmVkVmFyaWFibGVcclxuICAgICAgICAgICAgdmFyIEJsb2JCdWlsZGVyID0gd2luZG93LkJsb2JCdWlsZGVyIHx8IHdpbmRvdy5XZWJLaXRCbG9iQnVpbGRlciB8fCB3aW5kb3cuTW96QmxvYkJ1aWxkZXIgfHxcclxuICAgICAgICAgICAgICAgIHdpbmRvdy5NU0Jsb2JCdWlsZGVyLCBjYW5CbG9iID0gJGguaGFzQmxvYlN1cHBvcnQoKSwgYnl0ZVN0ciwgYXJyYXlCdWZmZXIsIGludEFycmF5LCBpLCBtaW1lU3RyLCBiYixcclxuICAgICAgICAgICAgICAgIGNhblByb2NlZWQgPSAoY2FuQmxvYiB8fCBCbG9iQnVpbGRlcikgJiYgd2luZG93LmF0b2IgJiYgd2luZG93LkFycmF5QnVmZmVyICYmIHdpbmRvdy5VaW50OEFycmF5O1xyXG4gICAgICAgICAgICBpZiAoIWNhblByb2NlZWQpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChkYXRhVVJJLnNwbGl0KCcsJylbMF0uaW5kZXhPZignYmFzZTY0JykgPj0gMCkge1xyXG4gICAgICAgICAgICAgICAgYnl0ZVN0ciA9IGF0b2IoZGF0YVVSSS5zcGxpdCgnLCcpWzFdKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGJ5dGVTdHIgPSBkZWNvZGVVUklDb21wb25lbnQoZGF0YVVSSS5zcGxpdCgnLCcpWzFdKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBhcnJheUJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcihieXRlU3RyLmxlbmd0aCk7XHJcbiAgICAgICAgICAgIGludEFycmF5ID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlCdWZmZXIpO1xyXG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYnl0ZVN0ci5sZW5ndGg7IGkgKz0gMSkge1xyXG4gICAgICAgICAgICAgICAgaW50QXJyYXlbaV0gPSBieXRlU3RyLmNoYXJDb2RlQXQoaSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgbWltZVN0ciA9IGRhdGFVUkkuc3BsaXQoJywnKVswXS5zcGxpdCgnOicpWzFdLnNwbGl0KCc7JylbMF07XHJcbiAgICAgICAgICAgIGlmIChjYW5CbG9iKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEJsb2IoWyRoLmhhc0FycmF5QnVmZmVyVmlld1N1cHBvcnQoKSA/IGludEFycmF5IDogYXJyYXlCdWZmZXJdLCB7dHlwZTogbWltZVN0cn0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGJiID0gbmV3IEJsb2JCdWlsZGVyKCk7XHJcbiAgICAgICAgICAgIGJiLmFwcGVuZChhcnJheUJ1ZmZlcik7XHJcbiAgICAgICAgICAgIHJldHVybiBiYi5nZXRCbG9iKG1pbWVTdHIpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgYXJyYXlCdWZmZXIyU3RyaW5nOiBmdW5jdGlvbiAoYnVmZmVyKSB7XHJcbiAgICAgICAgICAgIC8vbm9pbnNwZWN0aW9uIEpTVW5yZXNvbHZlZFZhcmlhYmxlXHJcbiAgICAgICAgICAgIGlmICh3aW5kb3cuVGV4dERlY29kZXIpIHtcclxuICAgICAgICAgICAgICAgIC8vIG5vaW5zcGVjdGlvbiBKU1VucmVzb2x2ZWRGdW5jdGlvblxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBUZXh0RGVjb2RlcigndXRmLTgnKS5kZWNvZGUoYnVmZmVyKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB2YXIgYXJyYXkgPSBBcnJheS5wcm90b3R5cGUuc2xpY2UuYXBwbHkobmV3IFVpbnQ4QXJyYXkoYnVmZmVyKSksIG91dCA9ICcnLCBpID0gMCwgbGVuLCBjLCBjaGFyMiwgY2hhcjM7XHJcbiAgICAgICAgICAgIGxlbiA9IGFycmF5Lmxlbmd0aDtcclxuICAgICAgICAgICAgd2hpbGUgKGkgPCBsZW4pIHtcclxuICAgICAgICAgICAgICAgIGMgPSBhcnJheVtpKytdO1xyXG4gICAgICAgICAgICAgICAgc3dpdGNoIChjID4+IDQpIHsgLy8ganNoaW50IGlnbm9yZTpsaW5lXHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAwOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgMTpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIDI6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAzOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgNDpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIDU6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSA2OlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgNzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gMHh4eHh4eHhcclxuICAgICAgICAgICAgICAgICAgICAgICAgb3V0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoYyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgMTI6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAxMzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gMTEweCB4eHh4ICAgMTB4eCB4eHh4XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoYXIyID0gYXJyYXlbaSsrXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgb3V0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoKChjICYgMHgxRikgPDwgNikgfCAoY2hhcjIgJiAweDNGKSk7IC8vIGpzaGludCBpZ25vcmU6bGluZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgICAgICBjYXNlIDE0OlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyAxMTEwIHh4eHggIDEweHggeHh4eCAgMTB4eCB4eHh4XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoYXIyID0gYXJyYXlbaSsrXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhcjMgPSBhcnJheVtpKytdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvdXQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZSgoKGMgJiAweDBGKSA8PCAxMikgfCAvLyBqc2hpbnQgaWdub3JlOmxpbmVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoY2hhcjIgJiAweDNGKSA8PCA2KSB8ICAvLyBqc2hpbnQgaWdub3JlOmxpbmVcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoY2hhcjMgJiAweDNGKSA8PCAwKSk7IC8vIGpzaGludCBpZ25vcmU6bGluZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gb3V0O1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaXNIdG1sOiBmdW5jdGlvbiAoc3RyKSB7XHJcbiAgICAgICAgICAgIHZhciBhID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7XHJcbiAgICAgICAgICAgIGEuaW5uZXJIVE1MID0gc3RyO1xyXG4gICAgICAgICAgICBmb3IgKHZhciBjID0gYS5jaGlsZE5vZGVzLCBpID0gYy5sZW5ndGg7IGktLTspIHtcclxuICAgICAgICAgICAgICAgIGlmIChjW2ldLm5vZGVUeXBlID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaXNTdmc6IGZ1bmN0aW9uIChzdHIpIHtcclxuICAgICAgICAgICAgcmV0dXJuIHN0ci5tYXRjaCgvXlxccyo8XFw/eG1sL2kpICYmIChzdHIubWF0Y2goLzwhRE9DVFlQRSBzdmcvaSkgfHwgc3RyLm1hdGNoKC88c3ZnL2kpKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGdldE1pbWVUeXBlOiBmdW5jdGlvbiAoc2lnbmF0dXJlLCBjb250ZW50cywgdHlwZSkge1xyXG4gICAgICAgICAgICBzd2l0Y2ggKHNpZ25hdHVyZSkge1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmZkOGZmZTAnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmZkOGZmZTEnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmZkOGZmZTInOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnaW1hZ2UvanBlZyc7XHJcbiAgICAgICAgICAgICAgICBjYXNlICc4OTUwNEU0Nyc6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdpbWFnZS9wbmcnO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnNDc0OTQ2MzgnOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnaW1hZ2UvZ2lmJztcclxuICAgICAgICAgICAgICAgIGNhc2UgJzQ5NDkyYTAwJzpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2ltYWdlL3RpZmYnO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnNTI0OTQ2NDYnOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnaW1hZ2Uvd2VicCc7XHJcbiAgICAgICAgICAgICAgICBjYXNlICc2Njc0Nzk3MCc6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd2aWRlby8zZ3AnO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnNGY2NzY3NTMnOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAndmlkZW8vb2dnJztcclxuICAgICAgICAgICAgICAgIGNhc2UgJzFhNDVkZmEzJzpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3ZpZGVvL21rdic7XHJcbiAgICAgICAgICAgICAgICBjYXNlICcwMDAwMDFiYSc6XHJcbiAgICAgICAgICAgICAgICBjYXNlICcwMDAwMDFiMyc6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd2aWRlby9tcGVnJztcclxuICAgICAgICAgICAgICAgIGNhc2UgJzMwMjZiMjc1JzpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3ZpZGVvL3dtdic7XHJcbiAgICAgICAgICAgICAgICBjYXNlICcyNTUwNDQ0Nic6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdhcHBsaWNhdGlvbi9wZGYnO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnMjUyMTUwNTMnOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnYXBwbGljYXRpb24vcHMnO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnNTA0YjAzMDQnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnNTA0YjA1MDYnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnNTA0YjA1MDgnOlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAnYXBwbGljYXRpb24vemlwJztcclxuICAgICAgICAgICAgICAgIGNhc2UgJzM3N2FiY2FmJzpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2FwcGxpY2F0aW9uLzd6JztcclxuICAgICAgICAgICAgICAgIGNhc2UgJzc1NzM3NDYxJzpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2FwcGxpY2F0aW9uL3Rhcic7XHJcbiAgICAgICAgICAgICAgICBjYXNlICc3ODAxNzMwZCc6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdhcHBsaWNhdGlvbi9kbWcnO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHNpZ25hdHVyZS5zdWJzdHJpbmcoMCwgNikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnNDM1NzUzJzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnYXBwbGljYXRpb24veC1zaG9ja3dhdmUtZmxhc2gnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlICc0OTQ0MzMnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdhdWRpby9tcDMnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlICc0MjVhNjgnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdhcHBsaWNhdGlvbi9iemlwJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc2lnbmF0dXJlLnN1YnN0cmluZygwLCA0KSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJzQyNGQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2ltYWdlL2JtcCc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnZmZmYic6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnYXVkaW8vbXAzJztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICc0ZDVhJzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdhcHBsaWNhdGlvbi9leGUnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJzFmOWQnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJzFmYTAnOlxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ2FwcGxpY2F0aW9uL3ppcCc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnMWY4Yic6XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnYXBwbGljYXRpb24vZ3ppcCc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRlbnRzICYmICFjb250ZW50cy5tYXRjaChcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC9bXlxcdTAwMDAtXFx1MDA3Zl0vKSA/ICdhcHBsaWNhdGlvbi90ZXh0LXBsYWluJyA6IHR5cGU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuICAgICAgICBhZGRDc3M6IGZ1bmN0aW9uICgkZWwsIGNzcykge1xyXG4gICAgICAgICAgICAkZWwucmVtb3ZlQ2xhc3MoY3NzKS5hZGRDbGFzcyhjc3MpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgZ2V0RWxlbWVudDogZnVuY3Rpb24gKG9wdGlvbnMsIHBhcmFtLCB2YWx1ZSkge1xyXG4gICAgICAgICAgICByZXR1cm4gKCRoLmlzRW1wdHkob3B0aW9ucykgfHwgJGguaXNFbXB0eShvcHRpb25zW3BhcmFtXSkpID8gdmFsdWUgOiAkKG9wdGlvbnNbcGFyYW1dKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHVuaXFJZDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICByZXR1cm4gTWF0aC5yb3VuZChuZXcgRGF0ZSgpLmdldFRpbWUoKSkgKyAnXycgKyBNYXRoLnJvdW5kKE1hdGgucmFuZG9tKCkgKiAxMDApO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgaHRtbEVuY29kZTogZnVuY3Rpb24gKHN0ciwgdW5kZWZWYWwpIHtcclxuICAgICAgICAgICAgaWYgKHN0ciA9PT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZWYWwgfHwgbnVsbDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gc3RyLnJlcGxhY2UoLyYvZywgJyZhbXA7JylcclxuICAgICAgICAgICAgICAgIC5yZXBsYWNlKC88L2csICcmbHQ7JylcclxuICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8+L2csICcmZ3Q7JylcclxuICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9cIi9nLCAnJnF1b3Q7JylcclxuICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8nL2csICcmYXBvczsnKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHJlcGxhY2VUYWdzOiBmdW5jdGlvbiAoc3RyLCB0YWdzKSB7XHJcbiAgICAgICAgICAgIHZhciBvdXQgPSBzdHI7XHJcbiAgICAgICAgICAgIGlmICghdGFncykge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIG91dDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkLmVhY2godGFncywgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcclxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdmdW5jdGlvbicpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBvdXQgPSBvdXQuc3BsaXQoa2V5KS5qb2luKHZhbHVlKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIHJldHVybiBvdXQ7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBjbGVhbk1lbW9yeTogZnVuY3Rpb24gKCR0aHVtYikge1xyXG4gICAgICAgICAgICB2YXIgZGF0YSA9ICR0aHVtYi5pcygnaW1nJykgPyAkdGh1bWIuYXR0cignc3JjJykgOiAkdGh1bWIuZmluZCgnc291cmNlJykuYXR0cignc3JjJyk7XHJcbiAgICAgICAgICAgICRoLnJldm9rZU9iamVjdFVSTChkYXRhKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGZpbmRGaWxlTmFtZTogZnVuY3Rpb24gKGZpbGVQYXRoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZXBJbmRleCA9IGZpbGVQYXRoLmxhc3RJbmRleE9mKCcvJyk7XHJcbiAgICAgICAgICAgIGlmIChzZXBJbmRleCA9PT0gLTEpIHtcclxuICAgICAgICAgICAgICAgIHNlcEluZG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ZG9jdW1lbnQud2Via2l0UmVxdWVzdEZ1bGxzY3JlZW4gKi9cclxuICAgICAgICAgICAgICAgIC8qKiBAbmFtZXNwYWNlIEVsZW1lbnQuQUxMT1dfS0VZQk9BUkRfSU5QVVQgKi9cclxuICAgICAgICAgICAgICAgIGlmIChkZS5yZXF1ZXN0RnVsbHNjcmVlbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGRlLnJlcXVlc3RGdWxsc2NyZWVuKCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChkZS5tc1JlcXVlc3RGdWxsc2NyZWVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlLm1zUmVxdWVzdEZ1bGxzY3JlZW4oKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGUubW96UmVxdWVzdEZ1bGxTY3JlZW4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlLm1velJlcXVlc3RGdWxsU2NyZWVuKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGUud2Via2l0UmVxdWVzdEZ1bGxzY3JlZW4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZS53ZWJraXRSZXF1ZXN0RnVsbHNjcmVlbihFbGVtZW50LkFMTE9XX0tFWUJPQVJEX0lOUFVUKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIC8qKiBAbmFtZXNwYWNlIGRvY3VtZW50LmV4aXRGdWxsc2NyZWVuICovXHJcbiAgICAgICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBkb2N1bWVudC5tc0V4aXRGdWxsc2NyZWVuICovXHJcbiAgICAgICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBkb2N1bWVudC5tb3pDYW5jZWxGdWxsU2NyZWVuICovXHJcbiAgICAgICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBkb2N1bWVudC53ZWJraXRFeGl0RnVsbHNjcmVlbiAqL1xyXG4gICAgICAgICAgICAgICAgaWYgKGRvYy5leGl0RnVsbHNjcmVlbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGRvYy5leGl0RnVsbHNjcmVlbigpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoZG9jLm1zRXhpdEZ1bGxzY3JlZW4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZG9jLm1zRXhpdEZ1bGxzY3JlZW4oKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jLm1vekNhbmNlbEZ1bGxTY3JlZW4pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvYy5tb3pDYW5jZWxGdWxsU2NyZWVuKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jLndlYmtpdEV4aXRGdWxsc2NyZWVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9jLndlYmtpdEV4aXRGdWxsc2NyZWVuKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIG1vdmVBcnJheTogZnVuY3Rpb24gKGFyciwgb2xkSW5kZXgsIG5ld0luZGV4LCByZXZlcnNlT3JkZXIpIHtcclxuICAgICAgICAgICAgdmFyIG5ld0FyciA9ICQuZXh0ZW5kKHRydWUsIFtdLCBhcnIpO1xyXG4gICAgICAgICAgICBpZiAocmV2ZXJzZU9yZGVyKSB7XHJcbiAgICAgICAgICAgICAgICBuZXdBcnIucmV2ZXJzZSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChuZXdJbmRleCA+PSBuZXdBcnIubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgayA9IG5ld0luZGV4IC0gbmV3QXJyLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgIHdoaWxlICgoay0tKSArIDEpIHtcclxuICAgICAgICAgICAgICAgICAgICBuZXdBcnIucHVzaCh1bmRlZmluZWQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG5ld0Fyci5zcGxpY2UobmV3SW5kZXgsIDAsIG5ld0Fyci5zcGxpY2Uob2xkSW5kZXgsIDEpWzBdKTtcclxuICAgICAgICAgICAgaWYgKHJldmVyc2VPcmRlcikge1xyXG4gICAgICAgICAgICAgICAgbmV3QXJyLnJldmVyc2UoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gbmV3QXJyO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY2xlYW5ab29tQ2FjaGU6IGZ1bmN0aW9uICgkZWwpIHtcclxuICAgICAgICAgICAgdmFyICRjYWNoZSA9ICRlbC5jbG9zZXN0KCcua3Ytem9vbS1jYWNoZS10aGVtZScpO1xyXG4gICAgICAgICAgICBpZiAoISRjYWNoZS5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICRjYWNoZSA9ICRlbC5jbG9zZXN0KCcua3Ytem9vbS1jYWNoZScpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRjYWNoZS5yZW1vdmUoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGNsb3NlQnV0dG9uOiBmdW5jdGlvbiAoY3NzKSB7XHJcbiAgICAgICAgICAgIGNzcyA9IGNzcyA/ICdjbG9zZSAnICsgY3NzIDogJ2Nsb3NlJztcclxuICAgICAgICAgICAgcmV0dXJuICc8YnV0dG9uIHR5cGU9XCJidXR0b25cIiBjbGFzcz1cIicgKyBjc3MgKyAnXCIgYXJpYS1sYWJlbD1cIkNsb3NlXCI+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICA8c3BhbiBhcmlhLWhpZGRlbj1cInRydWVcIj4mdGltZXM7PC9zcGFuPlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJzwvYnV0dG9uPic7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBnZXRSb3RhdGlvbjogZnVuY3Rpb24gKHZhbHVlKSB7XHJcbiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUpIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgMjpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3JvdGF0ZVkoMTgwZGVnKSc7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDM6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdyb3RhdGUoMTgwZGVnKSc7XHJcbiAgICAgICAgICAgICAgICBjYXNlIDQ6XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdyb3RhdGUoMTgwZGVnKSByb3RhdGVZKDE4MGRlZyknO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA1OlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAncm90YXRlKDI3MGRlZykgcm90YXRlWSgxODBkZWcpJztcclxuICAgICAgICAgICAgICAgIGNhc2UgNjpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3JvdGF0ZSg5MGRlZyknO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA3OlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAncm90YXRlKDkwZGVnKSByb3RhdGVZKDE4MGRlZyknO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA4OlxyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAncm90YXRlKDI3MGRlZyknO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJyc7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIHNldFRyYW5zZm9ybTogZnVuY3Rpb24gKGVsLCB2YWwpIHtcclxuICAgICAgICAgICAgaWYgKCFlbCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGVsLnN0eWxlLnRyYW5zZm9ybSA9IHZhbDtcclxuICAgICAgICAgICAgZWwuc3R5bGUud2Via2l0VHJhbnNmb3JtID0gdmFsO1xyXG4gICAgICAgICAgICBlbC5zdHlsZVsnLW1vei10cmFuc2Zvcm0nXSA9IHZhbDtcclxuICAgICAgICAgICAgZWwuc3R5bGVbJy1tcy10cmFuc2Zvcm0nXSA9IHZhbDtcclxuICAgICAgICAgICAgZWwuc3R5bGVbJy1vLXRyYW5zZm9ybSddID0gdmFsO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgc2V0SW1hZ2VPcmllbnRhdGlvbjogZnVuY3Rpb24gKCRpbWcsICR6b29tSW1nLCB2YWx1ZSkge1xyXG4gICAgICAgICAgICBpZiAoISRpbWcgfHwgISRpbWcubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdmFyIGV2ID0gJ2xvYWQuZmlsZWlucHV0aW1hZ2VvcmllbnQnO1xyXG4gICAgICAgICAgICAkaW1nLm9mZihldikub24oZXYsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHZhciBpbWcgPSAkaW1nLmdldCgwKSwgem9vbUltZyA9ICR6b29tSW1nICYmICR6b29tSW1nLmxlbmd0aCA/ICR6b29tSW1nLmdldCgwKSA6IG51bGwsXHJcbiAgICAgICAgICAgICAgICAgICAgaCA9IGltZy5vZmZzZXRIZWlnaHQsIHcgPSBpbWcub2Zmc2V0V2lkdGgsIHIgPSAkaC5nZXRSb3RhdGlvbih2YWx1ZSk7XHJcbiAgICAgICAgICAgICAgICAkaW1nLmRhdGEoJ29yaWVudGF0aW9uJywgdmFsdWUpO1xyXG4gICAgICAgICAgICAgICAgaWYgKHpvb21JbWcpIHtcclxuICAgICAgICAgICAgICAgICAgICAkem9vbUltZy5kYXRhKCdvcmllbnRhdGlvbicsIHZhbHVlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA8IDUpIHtcclxuICAgICAgICAgICAgICAgICAgICAkaC5zZXRUcmFuc2Zvcm0oaW1nLCByKTtcclxuICAgICAgICAgICAgICAgICAgICAkaC5zZXRUcmFuc2Zvcm0oem9vbUltZywgcik7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdmFyIG9mZnNldEFuZ2xlID0gTWF0aC5hdGFuKHcgLyBoKSwgb3JpZ0ZhY3RvciA9IE1hdGguc3FydChNYXRoLnBvdyhoLCAyKSArIE1hdGgucG93KHcsIDIpKSxcclxuICAgICAgICAgICAgICAgICAgICBzY2FsZSA9ICFvcmlnRmFjdG9yID8gMSA6IChoIC8gTWF0aC5jb3MoTWF0aC5QSSAvIDIgKyBvZmZzZXRBbmdsZSkpIC8gb3JpZ0ZhY3RvcixcclxuICAgICAgICAgICAgICAgICAgICBzID0gJyBzY2FsZSgnICsgTWF0aC5hYnMoc2NhbGUpICsgJyknO1xyXG4gICAgICAgICAgICAgICAgJGguc2V0VHJhbnNmb3JtKGltZywgciArIHMpO1xyXG4gICAgICAgICAgICAgICAgJGguc2V0VHJhbnNm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JcbiAgICAgICAgICAgIHNlbGYuZm9ybWRhdGEgPSB7fTtcclxuICAgICAgICAgICAgc2VsZi51cGxvYWRDb3VudCA9IDA7XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkU3RhdHVzID0ge307XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkTG9nID0gW107XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkQXN5bmNDb3VudCA9IDA7XHJcbiAgICAgICAgICAgIHNlbGYubG9hZGVkSW1hZ2VzID0gW107XHJcbiAgICAgICAgICAgIHNlbGYudG90YWxJbWFnZXNDb3VudCA9IDA7XHJcbiAgICAgICAgICAgIHNlbGYuYWpheFJlcXVlc3RzID0gW107XHJcbiAgICAgICAgICAgIHNlbGYuY2xlYXJTdGFjaygpO1xyXG4gICAgICAgICAgICBzZWxmLmZpbGVCYXRjaENvbXBsZXRlZCA9IHRydWU7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5pc1ByZXZpZXdhYmxlKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnNob3dQcmV2aWV3ID0gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5pc0Vycm9yID0gZmFsc2U7XHJcbiAgICAgICAgICAgIHNlbGYuYWpheEFib3J0ZWQgPSBmYWxzZTtcclxuICAgICAgICAgICAgc2VsZi5jYW5jZWxsaW5nID0gZmFsc2U7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdDogZnVuY3Rpb24gKG9wdGlvbnMsIHJlZnJlc2hNb2RlKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgZiwgJGVsID0gc2VsZi4kZWxlbWVudCwgJGNvbnQsIHQsIHRtcDtcclxuICAgICAgICAgICAgc2VsZi5vcHRpb25zID0gb3B0aW9ucztcclxuICAgICAgICAgICAgJC5lYWNoKG9wdGlvbnMsIGZ1bmN0aW9uIChrZXksIHZhbHVlKSB7XHJcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKGtleSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ21pbkZpbGVDb3VudCc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbWF4RmlsZUNvdW50JzpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdtaW5GaWxlU2l6ZSc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbWF4RmlsZVNpemUnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ21heEZpbGVQcmV2aWV3U2l6ZSc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncmVzaXplSW1hZ2VRdWFsaXR5JzpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdyZXNpemVJZlNpemVNb3JlVGhhbic6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAncHJvZ3Jlc3NVcGxvYWRUaHJlc2hvbGQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ2luaXRpYWxQcmV2aWV3Q291bnQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ3pvb21Nb2RhbEhlaWdodCc6XHJcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnbWluSW1hZ2VIZWlnaHQnOlxyXG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ21heEltYWdlSGVpZ2h0JzpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdtaW5JbWFnZVdpZHRoJzpcclxuICAgICAgICAgICAgICAgICAgICBjYXNlICdtYXhJbWFnZVdpZHRoJzpcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZltrZXldID0gJGguZ2V0TnVtKHZhbHVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZltrZXldID0gdmFsdWU7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgaWYgKHNlbGYucnRsKSB7IC8vIHN3YXAgYnV0dG9ucyBmb3IgcnRsXHJcbiAgICAgICAgICAgICAgICB0bXAgPSBzZWxmLnByZXZpZXdab29tQnV0dG9uSWNvbnMucHJldjtcclxuICAgICAgICAgICAgICAgIHNlbGYucHJldmlld1pvb21CdXR0b25JY29ucy5wcmV2ID0gc2VsZi5wcmV2aWV3Wm9vbUJ1dHRvbkljb25zLm5leHQ7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdab29tQnV0dG9uSWNvbnMubmV4dCA9IHRtcDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoIXJlZnJlc2hNb2RlKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jbGVhbnVwKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi4kZm9ybSA9ICRlbC5jbG9zZXN0KCdmb3JtJyk7XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRUZW1wbGF0ZURlZmF1bHRzKCk7XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkRmlsZUF0dHIgPSAhJGguaXNFbXB0eSgkZWwuYXR0cignbmFtZScpKSA/ICRlbC5hdHRyKCduYW1lJykgOiAnZmlsZV9kYXRhJztcclxuICAgICAgICAgICAgdCA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdwcm9ncmVzcycpO1xyXG4gICAgICAgICAgICBzZWxmLnByb2dyZXNzVGVtcGxhdGUgPSB0LnJlcGxhY2UoJ3tjbGFzc30nLCBzZWxmLnByb2dyZXNzQ2xhc3MpO1xyXG4gICAgICAgICAgICBzZWxmLnByb2dyZXNzQ29tcGxldGVUZW1wbGF0ZSA9IHQucmVwbGFjZSgne2NsYXNzfScsIHNlbGYucHJvZ3Jlc3NDb21wbGV0ZUNsYXNzKTtcclxuICAgICAgICAgICAg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uZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyID0gc2VsZi5fY3JlYXRlQ29udGFpbmVyKCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yZWZyZXNoQ29udGFpbmVyKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGNvbnQgPSBzZWxmLiRjb250YWluZXI7XHJcbiAgICAgICAgICAgIHNlbGYuJGRyb3Bab25lID0gJGNvbnQuZmluZCgnLmZpbGUtZHJvcC16b25lJyk7XHJcbiAgICAgICAgICAgIHNlbGYuJHByb2dyZXNzID0gJGNvbnQuZmluZCgnLmt2LXVwbG9hZC1wcm9ncmVzcycpO1xyXG4gICAgICAgICAgICBzZWxmLiRidG5VcGxvYWQgPSAkY29udC5maW5kKCcuZmlsZWlucHV0LXVwbG9hZCcpO1xyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyID0gJGguZ2V0RWxlbWVudChvcHRpb25zLCAnZWxDYXB0aW9uQ29udGFpbmVyJywgJGNvbnQuZmluZCgnLmZpbGUtY2FwdGlvbicpKTtcclxuICAgICAgICAgICAgc2VsZi4kY2FwdGlvbiA9ICRoLmdldEVsZW1lbnQob3B0aW9ucywgJ2VsQ2FwdGlvblRleHQnLCAkY29udC5maW5kKCcuZmlsZS1jYXB0aW9uLW5hbWUnKSk7XHJcbiAgICAgICAgICAgIGlmICghJGguaXNFbXB0eShzZWxmLm1zZ1BsYWNlaG9sZGVyKSkge1xyXG4gICAgICAgICAgICAgICAgZiA9ICRlbC5hdHRyKCdtdWx0aXBsZScpID8gc2VsZi5maWxlUGx1cmFsIDogc2VsZi5maWxlU2luZ2xlO1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY2FwdGlvbi5hdHRyKCdwbGFjZWhvbGRlcicsIHNlbGYubXNnUGxhY2Vob2xkZXIucmVwbGFjZSgne2ZpbGVzfScsIGYpKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uSWNvbiA9IHNlbGYuJGNhcHRpb25Db250YWluZXIuZmluZCgnLmZpbGUtY2FwdGlvbi1pY29uJyk7XHJcbiAgICAgICAgICAgIHNlbGYuJHByZXZpZXdDb250YWluZXIgPSAkaC5nZXRFbGVtZW50KG9wdGlvbnMsICdlbFByZXZpZXdDb250YWluZXInLCAkY29udC5maW5kKCcuZmlsZS1wcmV2aWV3JykpO1xyXG4gICAgICAgICAgICBzZWxmLiRwcmV2aWV3ID0gJGguZ2V0RWxlbWVudChvcHRpb25zLCAnZWxQcmV2aWV3SW1hZ2UnLCAkY29udC5maW5kKCcuZmlsZS1wcmV2aWV3LXRodW1ibmFpbHMnKSk7XHJcbiAgICAgICAgICAgIHNlbGYuJHByZXZpZXdTdGF0dXMgPSAkaC5nZXRFbGVtZW50KG9wdGlvbnMsICdlbFByZXZpZXdTdGF0dXMnLCAkY29udC5maW5kKCcuZmlsZS1wcmV2aWV3LXN0YXR1cycpKTtcclxuICAgICAgICAgICAgc2VsZi4kZXJyb3JDb250YWluZXIgPSAkaC5nZXRFbGVtZW50KG9wdGlvbnMsICdlbEVycm9yQ29udGFpbmVyJyxcclxuICAgICAgICAgICAgICAgIHNlbGYuJHByZXZpZXdDb250YWluZXIuZmluZCgnLmt2LWZpbGVpbnB1dC1lcnJvcicpKTtcclxuICAgICAgICAgICAgc2VsZi5fdmFsaWRhdGVEaXNhYmxlZCgpO1xyXG4gICAgICAgICAgICBpZiAoISRoLmlzRW1wdHkoc2VsZi5tc2dFcnJvckNsYXNzKSkge1xyXG4gICAgICAgICAgICAgICAgJGguYWRkQ3NzKHNlbGYuJGVycm9yQ29udGFpbmVyLCBzZWxmLm1zZ0Vycm9yQ2xhc3MpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICghcmVmcmVzaE1vZGUpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuJGVycm9yQ29udGFpbmVyLmhpZGUoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0luaXRJZCA9ICdwcmV2aWV3LScgKyAkaC51bmlxSWQoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2luaXRQcmV2aWV3Q2FjaGUoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2luaXRQcmV2aWV3KHRydWUpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFByZXZpZXdBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2VsZi4kcGFyZW50Lmhhc0NsYXNzKCdmaWxlLWxvYWRpbmcnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuJGNvbnRhaW5lci5pbnNlcnRCZWZvcmUoc2VsZi4kcGFyZW50KTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLiRwYXJlbnQucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIXNlbGYuX2Vycm9yc0V4aXN0KCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLiRlcnJvckNvbnRhaW5lci5oaWRlKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fc2V0RmlsZURyb3Bab25lVGl0bGUoKTtcclxuICAgICAgICAgICAgaWYgKCRlbC5hdHRyKCdkaXNhYmxlZCcpKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmRpc2FibGUoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl9pbml0Wm9vbSgpO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5oaWRlVGh1bWJuYWlsQ29udGVudCkge1xyXG4gICAgICAgICAgICAgICAgJGguYWRkQ3NzKHNlbGYuJHByZXZpZXcsICdoaWRlLWNvbnRlbnQnKTtcclx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ICAgJzxkaXYgY2xhc3M9XCJpbnB1dC1ncm91cC1idG4gaW5wdXQtZ3JvdXAtYXBwZW5kXCI+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgICAge3JlbW92ZX1cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgICB7Y2FuY2VsfVxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICAgIHt1cGxvYWR9XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgICAge2Jyb3dzZX1cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnPC9kaXY+JztcclxuICAgICAgICAgICAgdE1haW4yID0gJ3twcmV2aWV3fVxcbjxkaXYgY2xhc3M9XCJrdi11cGxvYWQtcHJvZ3Jlc3Mga3YtaGlkZGVuXCI+PC9kaXY+XFxuPGRpdiBjbGFzcz1cImNsZWFyZml4XCI+PC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAne3JlbW92ZX1cXG57Y2FuY2VsfVxcbnt1cGxvYWR9XFxue2Jyb3dzZX1cXG4nO1xyXG4gICAgICAgICAgICB0UHJldmlldyA9ICc8ZGl2IGNsYXNzPVwiZmlsZS1wcmV2aWV3IHtjbGFzc31cIj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAge2Nsb3NlfScgK1xyXG4gICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPVwie2Ryb3BDbGFzc31cIj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz1cImZpbGUtcHJldmlldy10aHVtYm5haWxzXCI+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgIDwvZGl2PlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPVwiY2xlYXJmaXhcIj48L2Rpdj4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz1cImZpbGUtcHJldmlldy1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zPVwibW9kYWwtdGl0bGVcIj57aGVhZGluZ308L2g1PlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICAgIDxzcGFuIGNsYXNzPVwia3Ytem9vbS10aXRsZVwiPjwvc3Bhbj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgICA8ZGl2IGNsYXNzPVwia3Ytem9vbS1hY3Rpb25zXCI+e3RvZ2dsZWhlYWRlcn17ZnVsbHNjcmVlbn17Ym9yZGVybGVzc317Y2xvc2V9PC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgIDwvZGl2PlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPVwibW9kYWwtYm9keVwiPlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICAgIDxkaXYgY2xhc3M9XCJmbG9hdGluZy1idXR0b25zXCI+PC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgICAgPGRpdiBjbGFzcz1cImt2LXpvb20tYm9keSBmaWxlLXpvb20tY29udGVudCB7em9vbUZyYW1lQ2xhc3N9XCI+PC9kaXY+XFxuJyArICd7cHJldn0ge25leHR9XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgIDwvZGl2PlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnPC9kaXY+XFxuJztcclxuICAgICAgICAgICAgdFByb2dyZXNzID0gJzxkaXYgY2xhc3M9XCJwcm9ncmVzc1wiPlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPVwie2NsYXNzfVwiIHJvbGU9XCJwcm9ncmVzc2JhclwiJyArXHJcbiAgICAgICAgICAgICAgICAnIGFyaWEtdmFsdWVub3c9XCJ7cGVyY2VudH1cIiBhcmlhLXZhbHVlbWluPVwiMFwiIGFyaWEtdmFsdWVtYXg9XCIxMDBcIiBzdHlsZT1cIndpZHRoOntwZXJjZW50fSU7XCI+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgICAgICB7c3RhdHVzfVxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICAgPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnPC9kaXY+JztcclxuICAgICAgICAgICAgdFNpemUgPSAnIDxzYW1wPih7c2l6ZVRleHR9KTwvc2FtcD4nO1xyXG4gICAgICAgICAgICB0Rm9vdGVyID0gJzxkaXYgY2xhc3M9XCJmaWxlLXRodW1ibmFpbC1mb290ZXJcIj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz1cImZpbGUtZm9vdGVyLWNhcHRpb25cIiB0aXRsZT1cIntjYXB0aW9ufVwiPlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJyAgICAgICAgPGRpdiBjbGFzcz1cImZpbGUtY2FwdGlvbi1pbmZvXCI+e2NhcHRpb259PC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgICAgICA8ZGl2IGNsYXNzPVwiZmlsZS1zaXplLWluZm9cIj57c2l6ZX08L2Rpdj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnICAgIHtwcm9ncmVzc31cXG57aW5kaWNhdG9yfVxcbnthY3Rpb25zfVxcbicgK1xyXG4gICAgICAgICAgICAgICAgJzwvZGl2Pic7XHJcbiAgICAgICAgICAgIHRBY3Rpb25zID0gJzxkaXYgY2xhc3M9XCJmaWxlLWFjdGlvbnNcIj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz1cImZpbGUtZm9vdGVyLWJ1dHRvbnNcIj5cXG4nICtcclxuICAgICAgICAgICAgICAgICcgICAgICAgIHtkb3dubG9hZH0ge3VwbG9hZH0ge2RlbGV0ZX0ge3pvb219IHtvdGhlcn0nICtcclxuICAgICAgICAgICAgICAgICcgICAgPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnPC9kaXY+XFxuJyArXHJcbiAgICAgICAgICAgICAgICAne2RyYWd9XFxuJyArXHJcbiAgICAgICAgICAgICAgICAnPGRpdiBjbGFzcz1cImNsZWFyZml4XCI+PC9kaXY+JztcclxuICAgICAgICAgICAgLy9ub2luc3BlY3Rpb24gSHRtbFVua25vd25BdHRyaWJ1dGVcclxuICAgICAgICAgICAgdEFjdGlvbkRlbGV0ZSA9ICc8YnV0dG9uIHR5cGU9XCJidXR0b25cIiBjbGFzcz1cImt2LWZpbGUtcmVtb3ZlIHtyZW1vdmVDbGFzc31cIiAnICtcclxuICAgICAgICAgICAgICAgICd0aXRsZT1cIntyZW1vdmVUaXRsZX1cIiB7ZGF0YVVybH17ZGF0YUtleX0+e3JlbW92ZUljb259PC9idXR0b24+XFxuJztcclxuICAgICAgICAgICAgdEFjdGlvblVwbG9hZCA9ICc8YnV0dG9uIHR5cGU9XCJidXR0b25cIiBjbGFzcz1cImt2LWZpbGUtdXBsb2FkIHt1cGxvYWRDbGFzc31cIiB0aXRsZT1cInt1cGxvYWRUaXRsZX1cIj4nICtcclxuICAgICAgICAgICAgICAgICd7dXBsb2FkSWNvbn08L2J1dHRvbj4nO1xyXG4gICAgICAgICAgICB0QWN0aW9uRG93bmxvYWQgPSAnPGEgY2xhc3M9XCJrdi1maWxlLWRvd25sb2FkIHtkb3dubG9hZENsYXNzfVwiIHRpdGxlPVwie2Rvd25sb2FkVGl0bGV9XCIgJyArXHJcbiAgICAgICAgICAgICAgICAnaHJlZj1cIntkb3dubG9hZFVybH1cIiBkb3dubG9hZD1cIntjYXB0aW9ufVwiIHRhcmdldD1cIl9ibGFua1wiPntkb3dubG9hZEljb259PC9hPic7XHJcbiAgICAgICAgICAgIHRBY3Rpb25ab29tID0gJzxidXR0b24gdHlwZT1cImJ1dHRvblwiIGNsYXNzPVwia3YtZmlsZS16b29tIHt6b29tQ2xhc3N9XCIgJyArXHJcbiAgICAgICAgICAgICA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ie2RhdGF9XCIgdHlwZT1cInt0eXBlfVwiJyArIHRTdHlsZSArICc+XFxuJyArICc8cGFyYW0gbmFtZT1cIm1vdmllXCIgdmFsdWU9XCJ7Y2FwdGlvbn1cIiAvPlxcbicgK1xyXG4gICAgICAgICAgICAgICAgJGguT0JKRUNUX1BBUkFNUyArICcgJyArICRoLkRFRkFVTFRfUFJFVklFVyArICdcXG48L29iamVjdD5cXG4nO1xyXG4gICAgICAgICAgICB0T3RoZXIgPSAnPGRpdiBjbGFzcz1cImt2LXByZXZpZXctZGF0YSBmaWxlLXByZXZpZXctb3RoZXItZnJhbWVcIicgKyB0U3R5bGUgKyAnPlxcbicgKyAkaC5ERUZBVUxUX1BSRVZJRVcgKyAnXFxuPC9kaXY+XFxuJztcclxuICAgICAgICAgICAgdFpvb21DYWNoZSA9ICc8ZGl2IGNsYXNzPVwia3Ytem9vbS1jYWNoZVwiIHN0eWxlPVwiZGlzcGxheTpub25lXCI+e3pvb21Db250ZW50fTwvZGl2Pic7XHJcbiAgICAgICAgICAgIHZEZWZhdWx0RGltID0ge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJzEwMCUnLCAnbWluLWhlaWdodCc6ICc0ODBweCd9O1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5faXNQZGZSZW5kZXJlZCgpKSB7XHJcbiAgICAgICAgICAgICAgICB0UGRmID0gc2VsZi5wZGZSZW5kZXJlclRlbXBsYXRlLnJlcGxhY2UoJ3tyZW5kZXJlcn0nLCBzZWxmLl9lbmNvZGVVUkkoc2VsZi5wZGZSZW5kZXJlclVybCkpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuZGVmYXVsdHMgPSB7XHJcbiAgICAgICAgICAgICAgICBsYXlvdXRUZW1wbGF0ZXM6IHtcclxuICAgICAgICAgICAgICAgICAgICBtYWluMTogdE1haW4xLFxyXG4gICAgICAgICAgICAgICAgICAgIG1haW4yOiB0TWFpbjIsXHJcbiAgICAgICAgICAgICAgICAgICAgcHJldmlldzogdFByZXZpZXcsXHJcbiAgICAgICAgICAgICAgICAgICAgY2xvc2U6IHRDbG9zZSxcclxuICAgICAgICAgICAgICAgICAgICBmaWxlSWNvbjogdEZpbGVJY29uLFxyXG4gICAgICAgICAgICAgICAgICAgIGNhcHRpb246IHRDYXB0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgIG1vZGFsTWFpbjogdE1vZGFsTWFpbixcclxuICAgICAgICAgICAgICAgICAgICBtb2RhbDogdE1vZGFsLFxyXG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiB0UHJvZ3Jlc3MsXHJcbiAgICAgICAgICAgICAgICAgICAgc2l6ZTogdFNpemUsXHJcbiAgICAgICAgICAgICAgICAgICAgZm9vdGVyOiB0Rm9vdGVyLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGljYXRvcjogdEluZGljYXRvcixcclxuICAgICAgICAgICAgICAgICAgICBhY3Rpb25zOiB0QWN0aW9ucyxcclxuICAgICAgICAgICAgICAgICAgICBhY3Rpb25EZWxldGU6IHRBY3Rpb25EZWxldGUsXHJcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uVXBsb2FkOiB0QWN0aW9uVXBsb2FkLFxyXG4gICAgICAgICAgICAgICAgICAgIGFjdGlvbkRvd25sb2FkOiB0QWN0aW9uRG93bmxvYWQsXHJcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uWm9vbTogdEFjdGlvblpvb20sXHJcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uRHJhZzogdEFjdGlvbkRyYWcsXHJcbiAgICAgICAgICAgICAgICAgICAgYnRuRGVmYXVsdDogdEJ0bkRlZmF1bHQsXHJcbiAgICAgICAgICAgICAgICAgICAgYnRuTGluazogdEJ0bkxpbmssXHJcbiAgICAgICAgICAgICAgICAgICAgYnRuQnJvd3NlOiB0QnRuQnJvd3NlLFxyXG4gICAgICAgICAgICAgICAgICAgIHpvb21DYWNoZTogdFpvb21DYWNoZVxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIHByZXZpZXdNYXJrdXBUYWdzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGFnQmVmb3JlMTogdFRhZ0JlZjEsXHJcbiAgICAgICAgICAgICAgICAgICAgdGFnQmVmb3JlMjogdFRhZ0JlZjIsXHJcbiAgICAgICAgICAgICAgICAgICAgdGFnQWZ0ZXI6IHRUYWdBZnRcclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBwcmV2aWV3Q29udGVudFRlbXBsYXRlczoge1xyXG4gICAgICAgICAgICAgICAgICAgIGdlbmVyaWM6IHRHZW5lcmljLFxyXG4gICAgICAgICAgICAgICAgICAgIGh0bWw6IHRIdG1sLFxyXG4gICAgICAgICAgICAgICAgICAgIGltYWdlOiB0SW1hZ2UsXHJcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogdFRleHQsXHJcbiAgICAgICAgICAgICAgICAgICAgb2ZmaWNlOiB0T2ZmaWNlLFxyXG4gICAgICAgICAgICAgICAgICAgIGdkb2NzOiB0R2RvY3MsXHJcbiAgICAgICAgICAgICAgICAgICAgdmlkZW86IHRWaWRlbyxcclxuICAgICAgICAgICAgICAgICAgICBhdWRpbzogdEF1ZGlvLFxyXG4gICAgICAgICAgICAgICAgICAgIGZsYXNoOiB0Rmxhc2gsXHJcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0OiB0T2JqZWN0LFxyXG4gICAgICAgICAgICAgICAgICAgIHBkZjogdFBkZixcclxuICAgICAgICAgICAgICAgICAgICBvdGhlcjogdE90aGVyXHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgYWxsb3dlZFByZXZpZXdUeXBlczogWydpbWFnZScsICdodG1sJywgJ3RleHQnLCAndmlkZW8nLCAnYXVkaW8nLCAnZmxhc2gnLCAncGRmJywgJ29iamVjdCddLFxyXG4gICAgICAgICAgICAgICAgcHJldmlld1RlbXBsYXRlczoge30sXHJcbiAgICAgICAgICAgICAgICBwcmV2aWV3U2V0dGluZ3M6IHtcclxuICAgICAgICAgICAgICAgICAgICBpbWFnZToge3dpZHRoOiAnYXV0bycsIGhlaWdodDogJ2F1dG8nLCAnbWF4LXdpZHRoJzogJzEwMCUnLCAnbWF4LWhlaWdodCc6ICcxMDAlJ30sXHJcbiAgICAgICAgICAgICAgICAgICAgaHRtbDoge3dpZHRoOiAnMjEzcHgnLCBoZWlnaHQ6ICcxNjBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IHt3aWR0aDogJzIxM3B4JywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBvZmZpY2U6IHt3aWR0aDogJzIxM3B4JywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBnZG9jczoge3dpZHRoOiAnMjEzcHgnLCBoZWlnaHQ6ICcxNjBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIHZpZGVvOiB7d2lkdGg6ICcyMTNweCcsIGhlaWdodDogJzE2MHB4J30sXHJcbiAgICAgICAgICAgICAgICAgICAgYXVkaW86IHt3aWR0aDogJzEwMCUnLCBoZWlnaHQ6ICczMHB4J30sXHJcbiAgICAgICAgICAgICAgICAgICAgZmxhc2g6IHt3aWR0aDogJzIxM3B4JywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBvYmplY3Q6IHt3aWR0aDogJzIxM3B4JywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBwZGY6IHt3aWR0aDogJzEwMCUnLCBoZWlnaHQ6ICcxNjBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIG90aGVyOiB7d2lkdGg6ICcyMTNweCcsIGhlaWdodDogJzE2MHB4J31cclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBwcmV2aWV3U2V0dGluZ3NTbWFsbDoge1xyXG4gICAgICAgICAgICAgICAgICAgIGltYWdlOiB7d2lkdGg6ICdhdXRvJywgaGVpZ2h0OiAnYXV0bycsICdtYXgtd2lkdGgnOiAnMTAwJScsICdtYXgtaGVpZ2h0JzogJzEwMCUnfSxcclxuICAgICAgICAgICAgICAgICAgICBodG1sOiB7d2lkdGg6ICcxMDAlJywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICB0ZXh0OiB7d2lkdGg6ICcxMDAlJywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBvZmZpY2U6IHt3aWR0aDogJzEwMCUnLCBoZWlnaHQ6ICcxNjBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIGdkb2NzOiB7d2lkdGg6ICcxMDAlJywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICB2aWRlbzoge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJ2F1dG8nfSxcclxuICAgICAgICAgICAgICAgICAgICBhdWRpbzoge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJzMwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBmbGFzaDoge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJ2F1dG8nfSxcclxuICAgICAgICAgICAgICAgICAgICBvYmplY3Q6IHt3aWR0aDogJzEwMCUnLCBoZWlnaHQ6ICdhdXRvJ30sXHJcbiAgICAgICAgICAgICAgICAgICAgcGRmOiB7d2lkdGg6ICcxMDAlJywgaGVpZ2h0OiAnMTYwcHgnfSxcclxuICAgICAgICAgICAgICAgICAgICBvdGhlcjoge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJzE2MHB4J31cclxuICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICBwcmV2aWV3Wm9vbVNldHRpbmdzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2U6IHt3aWR0aDogJ2F1dG8nLCBoZWlnaHQ6ICdhdXRvJywgJ21heC13aWR0aCc6ICcxMDAlJywgJ21heC1oZWlnaHQnOiAnMTAwJSd9LFxyXG4gICAgICAgICAgICAgICAgICAgIGh0bWw6IHZEZWZhdWx0RGltLFxyXG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IHZEZWZhdWx0RGltLFxyXG4gICAgICAgICAgICAgICAgICAgIG9mZmljZToge3dpZHRoOiAnMTAwJScsIGhlaWdodDogJzEwMCUnLCAnbWF4LXdpZHRoJzogJzEwMCUnLCAnbWluLWhlaWdodCc6ICc0ODBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIGdkb2NzOiB7d2lkdGg6ICcxMDAlJywgaGVpZ2h0OiAnMTAwJScsICdtYXgtd2lkdGgnOiAnMTAwJScsICdtaW4taGVpZ2h0JzogJzQ4MHB4J30sXHJcbiAgICAgICAgICAgICAgICAgICAgdmlkZW86IHt3aWR0aDogJ2F1dG8nLCBoZWlnaHQ6ICcxMDAlJywgJ21heC13aWR0aCc6ICcxMDAlJ30sXHJcbiAgICAgICAgICAgICAgICAgICAgYXVkaW86IHt3aWR0aDogJzEwMCUnLCBoZWlnaHQ6ICczMHB4J30sXHJcbiAgICAgICAgICAgICAgICAgICAgZmxhc2g6IHt3aWR0aDogJ2F1dG8nLCBoZWlnaHQ6ICc0ODBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdDoge3dpZHRoOiAnYXV0bycsIGhlaWdodDogJzEwMCUnLCAnbWF4LXdpZHRoJzogJzEwMCUnLCAnbWluLWhlaWdodCc6ICc0ODBweCd9LFxyXG4gICAgICAgICAgICAgICAgICAgIHBkZjogdkRlZmF1bHREaW0sXHJcbiAgICAgICAgICAgICAgICAgICAgb3RoZXI6IHt3aWR0aDogJ2F1dG8nLCBoZWlnaHQ6ICcxMDAlJywgJ21pbi1oZWlnaHQnOiAnNDgwcHgnfVxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIG1pbWVUeXBlQWxpYXNlczoge1xyXG4gICAgICAgICAgICAgICAgICAgICd2aWRlby9xdWlja3RpbWUnOiAndmlkZW8vbXA0J1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIGZpbGVUeXBlU2V0dGluZ3M6IHtcclxuICAgICAgICAgICAgICAgICAgICBpbWFnZTogZnVuY3Rpb24gKHZUeXBlLCB2TmFtZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKCRoLmNvbXBhcmUodlR5cGUsICdpbWFnZS4qJykgJiYgISRoLmNvbXBhcmUodlR5cGUsIC8odGlmZj98d21mKSQvaSkgfHxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRoLmNvbXBhcmUodk5hbWUsIC9cXC4oZ2lmfHBuZ3xqcGU/ZykkL2kpKTtcclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIGh0bWw6IGZ1bmN0aW9uICh2VHlwZSwgdk5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRoLmNvbXBhcmUodlR5cGUsICd0ZXh0L2h0bWwnKSB8fCAkaC5jb21wYXJlKHZOYW1lLCAvXFwuKGh0bXxodG1sKSQvaSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBvZmZpY2U6IGZ1bmN0aW9uICh2VHlwZSwgdk5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRoLmNvbXBhcmUodlR5cGUsIC8od29yZHxleGNlbHxwb3dlcnBvaW50fG9mZmljZSkkL2kpIHx8XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaC5jb21wYXJlKHZOYW1lLCAvXFwuKGRvY3g/fHhsc3g/fHBwdHg/fHBwc3xwb3R4PykkL2kpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgZ2RvY3M6IGZ1bmN0aW9uICh2VHlwZSwgdk5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRoLmNvbXBhcmUodlR5cGUsIC8od29yZHxleGNlbHxwb3dlcnBvaW50fG9mZmljZXxpd29yay1wYWdlc3x0aWZmPykkL2kpIHx8XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaC5jb21wYXJlKHZOYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC9cXC4oZG9jeD98eGxzeD98cHB0eD98cHBzfHBvdHg/fHJ0ZnxvZHN8b2R0fHBhZ2VzfGFpfGR4Znx0dGZ8dGlmZj98d21mfGU/cHMpJC9pKTtcclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IGZ1bmN0aW9uICh2VHlwZSwgdk5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRoLmNvbXBhcmUodlR5cGUsICd0ZXh0LionKSB8fCAkaC5jb21wYXJlKHZOYW1lLCAvXFwuKHhtbHxqYXZhc2NyaXB0KSQvaSkgfHxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRoLmNvbXBhcmUodk5hbWUsIC9cXC4odHh0fG1kfGNzdnxuZm98aW5pfGpzb258cGhwfGpzfGNzcykkL2kpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sXHJcbiAgICAgICAgICAgICAgICAgICAgdmlkZW86IGZ1bmN0aW9uICh2VHlwZSwgdk5hbWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRoLmNvbXBhcmUodlR5cGUsICd2aWRlby4qJykgJiYgKCRoLmNvbXBhcmUodlR5cGUsIC8ob2dnfG1wNHxtcD9nfG1vdnx3ZWJtfDNncCkkL2kpIHx8XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaC5jb21wYXJlKHZOYW1lLCAvXFwuKG9nP3xtcDR8d2VibXxtcD9nfG1vdnwzZ3ApJC9pKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBhdWRpbzogZnVuY3Rpb24gKHZUeXBlLCB2TmFtZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGguY29tcGFyZSh2VHlwZSwgJ2F1ZGlvLionKSAmJiAoJGguY29tcGFyZSh2TmFtZSwgLyhvZ2d8bXAzfG1wP2d8d2F2KSQvaSkgfHxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRoLmNvbXBhcmUodk5hbWUsIC9cXC4ob2c/fG1wM3xtcD9nfHdhdikkL2kpKTtcclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIGZsYXNoOiBmdW5jdGlvbiAodlR5cGUsIHZOYW1lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkaC5jb21wYXJlKHZUeXBlLCAnYXBwbGljYXRpb24veC1zaG9ja3dhdmUtZmxhc2gnLCB0cnVlKSB8fCAkaC5jb21wYXJlKHZOYW1lLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgL1xcLihzd2YpJC9pKTtcclxuICAgICAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgICAgIHBkZjogZnVuY3Rpb24gKHZUeXBlLCB2TmFtZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGguY29tcGFyZSh2VHlwZSwgJ2FwcGxpY2F0aW9uL3BkZicsIHRydWUpIHx8ICRoLmNvbXBhcmUodk5hbWUsIC9cXC4ocGRmKSQvaSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBvYmplY3Q6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgICAgICBvdGhlcjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgZmlsZUFjdGlvblNldHRpbmdzOiB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2hvd1JlbW92ZTogdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICBzaG93VXBsb2FkOiB0cnVlLFxyXG4gICAgICAgICAgICAgICAgICAgIHNob3dEb3dubG9hZDogdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICBzaG93Wm9vbTogdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICBzaG93RHJhZzogdHJ1ZSxcclxuICAgICAgICAgICAgICAgICAgICByZW1vdmVJY29uOiAnPGkgY2xhc3M9XCJnbHlwaGljb24gZ2x5cGhpY29uLXRyYXNoXCI+PC9pPicsXHJcbiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlQ2xhc3M6ICdidG4gYnRuLXNtIGJ0bi1rdiBidG4tZGVmYXVsdCBidG4tb3V0bGluZS1zZWNvbmRhcnknLFxyXG4gICAgICAgICAgICAgICAgICAgIHJlbW92ZUVycm9yQ2xhc3M6ICdidG4gYnRuLXNtIGJ0bi1rdiBidG4tZGFuZ2VyJyxcclxuICAgICAgICAgICAgICAgICAgICByZW1vdmVUaXRsZTogJ1JlbW92ZSBmaWxlJyxcclxuICAgICAgICAgICAgICAgICAgICB1cGxvYWRJY29uOiAnPGkgY2xhc3M9XCJnbHlwaGljb24gZ2x5cGhpY29uLXVwbG9hZFwiPjwvaT4nLFxyXG4gICAgICAgICAgICAgICAgICAgIHVwbG9hZENsYXNzOiAnYnRuIGJ0bi1zbSBidG4ta3YgYnRuLWRlZmF1bHQgYnRuLW91dGxpbmUtc2Vjb25kYXJ5JyxcclxuICAgICAgICAgICAgICAgICAgICB1cGxvYWRUaXRsZTogJ1VwbG9hZCBmaWxlJyxcclxuICAgICAgICAgICAgICAgICAgICB1cGxvYWRSZXRyeUljb246ICc8aSBjbGFzcz1cImdseXBoaWNvbiBnbHlwaGljb24tcmVwZWF0XCI+PC9pPicsXHJcbiAgICAgICAgICAgICAgICAgICAgdXBsb2FkUmV0cnlUaXRsZTogJ1JldHJ5IHVwbG9hZCcsXHJcbiAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRJY29uOiAnPGkgY2xhc3M9XCJnbHlwaGljb24gZ2x5cGhpY29uLWRvd25sb2FkXCI+PC9pPicsXHJcbiAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRDbGFzczogJ2J0biBidG4tc20gYnRuLWt2IGJ0bi1kZWZhdWx0IGJ0bi1vdXRsaW5lLXNlY29uZGFyeScsXHJcbiAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRUaXRsZTogJ0Rvd25sb2FkIGZpbGUnLFxyXG4gICAgICAgICAgICAgICAgICAgIHpvb21JY29uOiAnPGkgY2xhc3M9XCJnbHlwaGljb24gZ2x5cGhpY29uLXpvb20taW5cIj48L2k+JyxcclxuICAgICAgICAgICAgICAgICAgICB6b29tQ2xhc3M6ICdidG4gYnRuLXNtIGJ0bi1rdiBidG4tZGVmYXVsdCBidG4tb3V0bGluZS1zZWNvbmRhcnknLFxyXG4gICAgICAgICAgICAgICAgICAgIHpvb21UaXRsZTogJ1ZpZXcgRGV0YWlscycsXHJcbiAgICAgICAgICAgICAgICAgICAgZHJhZ0ljb246ICc8aSBjbGFzcz1cImdseXBoaWNvbiBnbHlwaGljb24tbW92ZVwiPjwvaT4nLFxyXG4gICAgICAgICAgICAgICAgICAgIGRyYWdDbGFzczogJ3RleHQtaW5mbycsXHJcbiAgICAgICAgICAgICAgICAgICAgZHJhZ1RpdGxlOiAnTW92ZSAvIFJlYXJyYW5nZScsXHJcbiAgICAgICAgICAgICAgICAgICAgZHJhZ1NldHRpbmdzOiB7fSxcclxuICAgICAgICAgICAgICAgICAgICBpbmRpY2F0b3JOZXc6ICc8aSBjbGFzcz1cImdseXBoaWNvbiBnbHlwaGljb24tcGx1cy1zaWduIHRleHQtd2FybmluZ1wiPjwvaT4nLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGljYXRvclN1Y2Nlc3M6ICc8aSBjbGFzcz1cImdseXBoaWNvbiBnbHlwaGljb24tb2stc2lnbiB0ZXh0LXN1Y2Nlc3NcIj48L2k+JyxcclxuICAgICAgICAgICAgICAgICAgICBpbmRpY2F0b3JFcnJvcjogJzxpIGNsYXNzPVwiZ2x5cGhpY29uIGdseXBoaWNvbi1leGNsYW1hdGlvbi1zaWduIHRleHQtZGFuZ2VyXCI+PC9pPicsXHJcbiAgICAgICAgICAgICAgICAgICAgaW5kaWNhdG9yTG9hZGluZzogJzxpIGNsYXNzPVwiZ2x5cGhpY29uIGdseXBoaWNvbi1ob3VyZ2xhc3MgdGV4dC1tdXRlZFwiPjwvaT4nLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGljYXRvck5ld1RpdGxlOiAnTm90IHVwbG9hZGVkIHlldCcsXHJcbiAgICAgICAgICAgICAgICAgICAgaW5kaWNhdG9yU3VjY2Vzc1RpdGxlOiAnVXBsb2FkZWQnLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGljYXRvckVycm9yVGl0bGU6ICdVcGxvYWQgRXJyb3InLFxyXG4gICAgICAgICAgICAgICAgICAgIGluZGljYXRvckxvYWRpbmdUaXRsZTogJ1VwbG9hZGluZyAuLi4nXHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICQuZWFjaChzZWxmLmRlZmF1bHRzLCBmdW5jdGlvbiAoa2V5LCBzZXR0aW5nKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSAnYWxsb3dlZFByZXZpZXdUeXBlcycpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5hbGxvd2VkUHJldmlld1R5cGVzID09PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5hbGxvd2VkUHJldmlld1R5cGVzID0gc2V0dGluZztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgc2VsZltrZXldID0gJC5leHRlbmQodHJ1ZSwge30sIHNldHRpbmcsIHNlbGZba2V5XSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9pbml0UHJldmlld1RlbXBsYXRlcygpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRQcmV2aWV3VGVtcGxhdGVzOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgdGFncyA9IHNlbGYucHJldmlld01hcmt1cFRhZ3MsIHRhZ0JlZiwgdGFnQWZ0ID0gdGFncy50YWdBZnRlcjtcclxuICAgICAgICAgICAgJC5lYWNoKHNlbGYucHJldmlld0NvbnRlbnRUZW1wbGF0ZXMsIGZ1bmN0aW9uIChrZXksIHZhbHVlKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eShzZWxmLnByZXZpZXdUZW1wbGF0ZXNba2V5XSkpIHtcclxuICAgICAgICAgICAgICAgICAgICB0YWdCZWYgPSB0YWdzLnRhZ0JlZm9yZTI7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGtleSA9PT0gJ2dlbmVyaWMnIHx8IGtleSA9PT0gJ2ltYWdlJyB8fCBrZXkgPT09ICdodG1sJyB8fCBrZXkgPT09ICd0ZXh0Jykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdCZWYgPSB0YWdzLnRhZ0JlZm9yZTE7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLl9pc1BkZlJlbmRlcmVkKCkgJiYga2V5ID09PSAncGRmJykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdCZWYgPSB0YWdCZWYucmVwbGFjZSgna3YtZmlsZS1jb250ZW50JywgJ2t2LWZpbGUtY29udGVudCBrdi1wZGYtcmVuZGVyZWQnKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3VGVtcGxhdGVzW2tleV0gPSB0YWdCZWYgKyB2YWx1ZSArIHRhZ0FmdDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdFByZXZpZXdDYWNoZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlID0ge1xyXG4gICAgICAgICAgICAgICAgZGF0YToge30sXHJcbiAgICAgICAgICAgICAgICBpbml0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSBzZWxmLmluaXRpYWxQcmV2aWV3O1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb250ZW50Lmxlbmd0aCA+IDAgJiYgISRoLmlzQXJyYXkoY29udGVudCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudCA9IGNvbnRlbnQuc3BsaXQoc2VsZi5pbml0aWFsUHJldmlld0RlbGltaXRlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlLmRhdGEgPSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZzogc2VsZi5pbml0aWFsUHJldmlld0NvbmZpZyxcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGFnczogc2VsZi5pbml0aWFsUHJldmlld1RodW1iVGFnc1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgY291bnQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gISFzZWxmLnByZXZpZXdDYWNoZS5kYXRhICYmICEhc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS5jb250ZW50ID9cclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS5jb250ZW50Lmxlbmd0aCA6IDA7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoaSwgaXNEaXNhYmxlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBpbmQgPSAnaW5pdF8nICsgaSwgZGF0YSA9IHNlbGYucHJldmlld0NhY2hlLmRhdGEsIGNvbmZpZyA9IGRhdGEuY29uZmlnW2ldLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50ID0gZGF0YS5jb250ZW50W2ldLCBwcmV2aWV3SWQgPSBzZWxmLnByZXZpZXdJbml0SWQgKyAnLScgKyBpbmQsIG91dCwgJHRtcCwgY2F0LCBmdHIsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZuYW1lLCBmdHlwZSwgZnJhbWVDbGFzcywgYXNEYXRhID0gJGguaWZTZXQoJ3ByZXZpZXdBc0RhdGEnLCBjb25maWcsIHNlbGYuaW5pdGlhbFByZXZpZXdBc0RhdGEpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhID0gY29uZmlnID8ge3RpdGxlOiBjb25maWcudGl0bGUgfHwgbnVsbCwgYWx0OiBjb25maWcuYWx0IHx8IG51bGx9IDoge3RpdGxlOiBudWxsLCBhbHQ6IG51bGx9LFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJzZVRlbXBsYXRlID0gZnVuY3Rpb24gKGNhdCwgZGF0LCBmbiwgZnQsIGlkLCBmdHIsIGluZCwgZmMsIHQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZjID0gJyBmaWxlLXByZXZpZXctaW5pdGlhbCAnICsgJGguU09SVF9DU1MgKyAoZmMgPyAnICcgKyBmYyA6ICcnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZWxmLl9nZW5lcmF0ZVByZXZpZXdUZW1wbGF0ZShjYXQsIGRhdCwgZm4sIGZ0LCBpZCwgZmFsc2UsIG51bGwsIGZjLCBmdHIsIGluZCwgdCwgYSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFjb250ZW50KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnJztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaXNEaXNhYmxlZCA9IGlzRGlzYWJsZWQgPT09IHVuZGVmaW5lZCA/IHRydWUgOiBpc0Rpc2FibGVkO1xyXG4gICAgICAgICAgICAgICAgICAgIGNhdCA9ICRoLmlmU2V0KCd0eXBlJywgY29uZmlnLCBzZWxmLmluaXRpYWxQcmV2aWV3RmlsZVR5cGUgfHwgJ2dlbmVyaWMnKTtcclxuICAgICAgICAgICAgICAgICAgICBmbmFtZSA9ICRoLmlmU2V0KCdmaWxlbmFtZScsIGNvbmZpZywgJGguaWZTZXQoJ2NhcHRpb24nLCBjb25maWcpKTtcclxuICAgICAgICAgICAgICAgICAgICBmdHlwZSA9ICRoLmlmU2V0KCdmaWxldHlwZScsIGNvbmZpZywgY2F0KTtcclxuICAgICAgICAgICAgICAgICAgICBmdHIgPSBzZWxmLnByZXZpZXdDYWNoZS5mb290ZXIoaSwgaXNEaXNhYmxlZCwgKGNvbmZpZyAmJiBjb25maWcuc2l6ZSB8fCBudWxsKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgZnJhbWVDbGFzcyA9ICRoLmlmU2V0KCdmcmFtZUNsYXNzJywgY29uZmlnKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoYXNEYXRhKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dCA9IHBhcnNlVGVtcGxhdGUoY2F0LCBjb250ZW50LCBmbmFtZSwgZnR5cGUsIHByZXZpZXdJZCwgZnRyLCBpbmQsIGZyYW1lQ2xhc3MpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dCA9IHBhcnNlVGVtcGxhdGUoJ2dlbmVyaWMnLCBjb250ZW50LCBmbmFtZSwgZnR5cGUsIHByZXZpZXdJZCwgZnRyLCBpbmQsIGZyYW1lQ2xhc3MsIGNhdClcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5zZXRUb2tlbnMoeydjb250ZW50JzogZGF0YS5jb250ZW50W2ldfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhZ3MubGVuZ3RoICYmIGRhdGEudGFnc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBvdXQgPSAkaC5yZXBsYWNlVGFncyhvdXQsIGRhdGEudGFnc1tpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIC8qKiBAbmFtZXNwYWNlIGNvbmZpZy5mcmFtZUF0dHIgKi9cclxuICAgICAgICAgICAgICAgICAgICBpZiAoISRoLmlzRW1wdHkoY29uZmlnKSAmJiAhJGguaXNFbXB0eShjb25maWcuZnJhbWVBdHRyKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkdG1wID0gJChkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKSkuaHRtbChvdXQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkdG1wLmZpbmQoJy5maWxlLXByZXZpZXctaW5pdGlhbCcpLmF0dHIoY29uZmlnLmZyYW1lQXR0cik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dCA9ICR0bXAuaHRtbCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkdG1wLnJlbW92ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3V0O1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gKGNvbnRlbnQsIGNvbmZpZywgdGFncywgYXBwZW5kKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRhdGEgPSBzZWxmLnByZXZpZXdDYWNoZS5kYXRhLCBpbmRleDtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoISRoLmlzQXJyYXkoY29udGVudCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudCA9IGNvbnRlbnQuc3BsaXQoc2VsZi5pbml0aWFsUHJldmlld0RlbGltaXRlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhcHBlbmQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBkYXRhLmNvbnRlbnQucHVzaChjb250ZW50KSAtIDE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29uZmlnW2luZGV4XSA9IGNvbmZpZztcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS50YWdzW2luZGV4XSA9IHRhZ3M7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBjb250ZW50Lmxlbmd0aCAtIDE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29udGVudCA9IGNvbnRlbnQ7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29uZmlnID0gY29uZmlnO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnRhZ3MgPSB0YWdzO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdDYWNoZS5kYXRhID0gZGF0YTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5kZXg7XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbiAoY29udGVudCwgY29uZmlnLCB0YWdzLCBhcHBlbmQpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgZGF0YSA9IHNlbGYucHJldmlld0NhY2hlLmRhdGEsIGksIGNoaztcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbnRlbnQgfHwgIWNvbnRlbnQubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCEkaC5pc0FycmF5KGNvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBjb250ZW50LnNwbGl0KHNlbGYuaW5pdGlhbFByZXZpZXdEZWxpbWl0ZXIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjaGsgPSBjb250ZW50LmZpbHRlcihmdW5jdGlvbiAobikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbiAhPT0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWNoay5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5jb250ZW50ID09PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5jb250ZW50ID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNvbmZpZyA9PT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29uZmlnID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhZ3MgPT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnRhZ3MgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFwcGVuZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29udGVudC5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnRlbnRbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLmNvbnRlbnQucHVzaChjb250ZW50W2ldKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29uZmlnLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29uZmlnW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5jb25maWcucHVzaChjb25maWdbaV0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0YWdzLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFnc1tpXSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEudGFncy5wdXNoKHRhZ3NbaV0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5jb250ZW50ID0gY29udGVudDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5jb25maWcgPSBjb25maWc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEudGFncyA9IHRhZ3M7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlLmRhdGEgPSBkYXRhO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIHVuc2V0OiBmdW5jdGlvbiAoaW5kZXgpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgY2hrID0gc2VsZi5wcmV2aWV3Q2FjaGUuY291bnQoKSwgcmV2ID0gc2VsZi5yZXZlcnNlUHJldmlld09yZGVyO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghY2hrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNoayA9PT0gMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdDYWNoZS5kYXRhLmNvbnRlbnQgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS5jb25maWcgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS50YWdzID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuaW5pdGlhbFByZXZpZXcgPSBbXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5pbml0aWFsUHJldmlld0NvbmZpZyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3VGh1bWJUYWdzID0gW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS5jb250ZW50ID0gJGguc3BsaWNlQXJyYXkoc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YS5jb250ZW50LCBpbmRleCwgcmV2KTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdDYWNoZS5kYXRhLmNvbmZpZyA9ICRoLnNwbGljZUFycmF5KHNlbGYucHJldmlld0NhY2hlLmRhdGEuY29uZmlnLCBpbmRleCwgcmV2KTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdDYWNoZS5kYXRhLnRhZ3MgPSAkaC5zcGxpY2VBcnJheShzZWxmLnByZXZpZXdDYWNoZS5kYXRhLnRhZ3MsIGluZGV4LCByZXYpO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIG91dDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gJycsIGNhcHRpb24sIGxlbiA9IHNlbGYucHJldmlld0NhY2hlLmNvdW50KCksIGksIGNvbnRlbnQ7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbiA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge2NvbnRlbnQ6ICcnLCBjYXB0aW9uOiAnJ307XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50ID0gc2VsZi5wcmV2aWV3Q2FjaGUuZ2V0KGkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBodG1sID0gc2VsZi5yZXZlcnNlUHJldmlld09yZGVyID8gKGNvbnRlbnQgKyBodG1sKSA6IChodG1sICsgY29udGVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGNhcHRpb24gPSBzZWxmLl9nZXRNc2dTZWxlY3RlZChsZW4pO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7Y29udGVudDogaHRtbCwgY2FwdGlvbjogY2FwdGlvbn07XHJcbiAgICAgICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICAgICAgZm9vdGVyOiBmdW5jdGlvbiAoaSwgaXNEaXNhYmxlZCwgc2l6ZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YSB8fCB7fTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eShkYXRhLmNvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnJztcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCRoLmlzRW1wdHkoZGF0YS5jb25maWcpIHx8ICRoLmlzRW1wdHkoZGF0YS5jb25maWdbaV0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29uZmlnW2ldID0ge307XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlzRGlzYWJsZWQgPSBpc0Rpc2FibGVkID09PSB1bmRlZmluZWQgPyB0cnVlIDogaXNEaXNhYmxlZDtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgY29uZmlnID0gZGF0YS5jb25maWdbaV0sIGNhcHRpb24gPSAkaC5pZlNldCgnY2FwdGlvbicsIGNvbmZpZyksIGEsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gJGguaWZTZXQoJ3dpZHRoJywgY29uZmlnLCAnYXV0bycpLCB1cmwgPSAkaC5pZlNldCgndXJsJywgY29uZmlnLCBmYWxzZSksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGtleSA9ICRoLmlmU2V0KCdrZXknLCBjb25maWcsIG51bGwpLCBmcyA9IHNlbGYuZmlsZUFjdGlvblNldHRpbmdzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbml0UHJldmlld1Nob3dEZWwgPSBzZWxmLmluaXRpYWxQcmV2aWV3U2hvd0RlbGV0ZSB8fCBmYWxzZSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgZFVybCA9IGNvbmZpZy5kb3dubG9hZFVybCB8fCBzZWxmLmluaXRpYWxQcmV2aWV3RG93bmxvYWRVcmwgfHwgJycsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRGaWwgPSBjb25maWcuZmlsZW5hbWUgfHwgY29uZmlnLmNhcHRpb24gfHwgJycsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGluaXRQcmV2aWV3U2hvd0R3bCA9ICEhKGRVcmwpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzRGVsID0gJGguaWZTZXQoJ3Nob3dSZW1vdmUnLCBjb25maWcsICRoLmlmU2V0KCdzaG93UmVtb3ZlJywgZnMsIGluaXRQcmV2aWV3U2hvd0RlbCkpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzRHdsID0gJGguaWZTZXQoJ3Nob3dEb3dubG9hZCcsIGNvbmZpZywgJGguaWZTZXQoJ3Nob3dEb3dubG9hZCcsIGZzLCBpbml0UHJldmlld1Nob3dEd2wpKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgc1ptID0gJGguaWZTZXQoJ3Nob3dab29tJywgY29uZmlnLCAkaC5pZlNldCgnc2hvd1pvb20nLCBmcywgdHJ1ZSkpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzRHJnID0gJGguaWZTZXQoJ3Nob3dEcmFnJywgY29uZmlnLCAkaC5pZlNldCgnc2hvd0RyYWcnLCBmcywgdHJ1ZSkpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBkaXMgPSAodXJsID09PSBmYWxzZSkgJiYgaXNEaXNhYmxlZDtcclxuICAgICAgICAgICAgICAgICAgICBzRHdsID0gc0R3bCAmJiBjb25maWcuZG93bmxvYWRVcmwgIT09IGZhbHNlICYmICEhZFVybDtcclxuICAgICAgICAgICAgICAgICAgICBhID0gc2VsZi5fcmVuZGVyRmlsZUFjdGlvbnMoZmFsc2UsIHNEd2wsIHNEZWwsIHNabSwgc0RyZywgZGlzLCB1cmwsIGtleSwgdHJ1ZSwgZFVybCwgZEZpbCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdmb290ZXInKS5zZXRUb2tlbnMoe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAncHJvZ3Jlc3MnOiBzZWxmLl9yZW5kZXJUaHVtYlByb2dyZXNzKCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICdhY3Rpb25zJzogYSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgJ2NhcHRpb24nOiBjYXB0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAnc2l6ZSc6IHNlbGYuX2dldFNpemUoc2l6ZSksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICd3aWR0aCc6IHdpZHRoLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAnaW5kaWNhdG9yJzogJydcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuaW5pdCgpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICA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J1wiOiAnICsgbXNnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG1zZyA9ICdib290c3RyYXAtZmlsZWlucHV0OiAnICsgbXNnO1xyXG4gICAgICAgICAgICBpZiAodHlwZW9mIHdpbmRvdy5jb25zb2xlLmxvZyAhPT0gJ3VuZGVmaW5lZCcpIHtcclxuICAgICAgICAgICAgICAgIHdpbmRvdy5jb25zb2xlLmxvZyhtc2cpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgd2luZG93LmFsZXJ0KG1zZyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF92YWxpZGF0ZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHN0YXR1cyA9IHNlbGYuJGVsZW1lbnQuYXR0cigndHlwZScpID09PSAnZmlsZSc7XHJcbiAgICAgICAgICAgIGlmICghc3RhdHVzKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9sb2coJ1RoZSBpbnB1dCBcInR5cGVcIiBtdXN0IGJlIHNldCB0byBcImZpbGVcIiBmb3IgaW5pdGlhbGl6aW5nIHRoZSBcImJvb3RzdHJhcC1maWxlaW5wdXRcIiBwbHVnaW4uJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIHN0YXR1cztcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9lcnJvcnNFeGlzdDogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlcnIsICRlcnJMaXN0ID0gc2VsZi4kZXJyb3JDb250YWluZXIuZmluZCgnbGknKTtcclxuICAgICAgICAgICAgaWYgKCRlcnJMaXN0Lmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGVyciA9ICQoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2JykpLmh0bWwoc2VsZi4kZXJyb3JDb250YWluZXIuaHRtbCgpKTtcclxuICAgICAgICAgICAgJGVyci5maW5kKCcua3YtZXJyb3ItY2xvc2UnKS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgJGVyci5maW5kKCd1bCcpLnJlbW92ZSgpO1xyXG4gICAgICAgICAgICByZXR1cm4gISEkLnRyaW0oJGVyci50ZXh0KCkpLmxlbmd0aDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9lcnJvckhhbmRsZXI6IGZ1bmN0aW9uIChldnQsIGNhcHRpb24pIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBlcnIgPSBldnQudGFyZ2V0LmVycm9yLCBzaG93RXJyb3IgPSBmdW5jdGlvbiAobXNnKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zaG93RXJyb3IobXNnLnJlcGxhY2UoJ3tuYW1lfScsIGNhcHRpb24pKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgLyoqIEBuYW1lc3BhY2UgZXJyLk5PVF9GT1VORF9FUlIgKi9cclxuICAgICAgICAgICAgLyoqIEBuYW1lc3BhY2UgZXJyLlNFQ1VSSVRZX0VSUiAqL1xyXG4gICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBlcnIuTk9UX1JFQURBQkxFX0VSUiAqL1xyXG4gICAgICAgICAgICBpZiAoZXJyLmNvZGUgPT09IGVyci5OT1RfRk9VTkRfRVJSKSB7XHJcbiAgICAgICAgICAgICAgICBzaG93RXJyb3Ioc2VsZi5tc2dGaWxlTm90Rm91bmQpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaWYgKGVyci5jb2RlID09PSBlcnIuU0VDVVJJVFlfRVJSKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2hvd0Vycm9yKHNlbGYubXNnRmlsZVNlY3VyZWQpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyLmNvZGUgPT09IGVyci5OT1RfUkVBREFCTEVfRVJSKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dFcnJvcihzZWxmLm1zZ0ZpbGVOb3RSZWFkYWJsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyci5jb2RlID09PSBlcnIuQUJPUlRfRVJSKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93RXJyb3Ioc2VsZi5tc2dGaWxlUHJldmlld0Fib3J0ZWQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0Vycm9yKHNlbGYubXNnRmlsZVByZXZpZXdFcnJvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9hZGRFcnJvcjogZnVuY3Rpb24gKG1zZykge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlcnJvciA9IHNlbGYuJGVycm9yQ29udGFpbmVyO1xyXG4gICAgICAgICAgICBpZiAobXNnICYmICRlcnJvci5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICRlcnJvci5odG1sKHNlbGYuZXJyb3JDbG9zZUJ1dHRvbiArIG1zZyk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRlcnJvci5maW5kKCcua3YtZXJyb3ItY2xvc2UnKSwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5zaG93UHJldmlldyAmJiAhc2VsZi5nZXRGcmFtZXMoKS5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuY2xlYXIoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAkZXJyb3IuZmFkZU91dCgnc2xvdycpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sIDEwKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfc2V0VmFsaWRhdGlvbkVycm9yOiBmdW5jdGlvbiAoY3NzKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgY3NzID0gKGNzcyA/IGNzcyArICcgJyA6ICcnKSArICdoYXMtZXJyb3InO1xyXG4gICAgICAgICAgICBzZWxmLiRjb250YWluZXIucmVtb3ZlQ2xhc3MoY3NzKS5hZGRDbGFzcygnaGFzLWVycm9yJyk7XHJcbiAgICAgICAgICAgICRoLmFkZENzcyhzZWxmLiRjYXB0aW9uQ29udGFpbmVyLCAnaXMtaW52YWxpZCcpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3Jlc2V0RXJyb3JzOiBmdW5jdGlvbiAoZmFkZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlcnJvciA9IHNlbGYuJGVycm9yQ29udGFpbmVyO1xyXG4gICAgICAgICAgICBzZWxmLmlzRXJyb3IgPSBmYWxzZTtcclxuICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyLnJlbW92ZUNsYXNzKCdoYXMtZXJyb3InKTtcclxuICAgICAgICAgICAgc2VsZi4kY2FwdGlvbkNvbnRhaW5lci5yZW1vdmVDbGFzcygnaXMtaW52YWxpZCcpO1xyXG4gICAgICAgICAgICAkZXJyb3IuaHRtbCgnJyk7XHJcbiAgICAgICAgICAgIGlmIChmYWRlKSB7XHJcbiAgICAgICAgICAgICAgICAkZXJyb3IuZmFkZU91dCgnc2xvdycpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgJGVycm9yLmhpZGUoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3Nob3dGb2xkZXJFcnJvcjogZnVuY3Rpb24gKGZvbGRlcnMpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZXJyb3IgPSBzZWxmLiRlcnJvckNvbnRhaW5lciwgbXNnO1xyXG4gICAgICAgICAgICBpZiAoIWZvbGRlcnMpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoIXNlbGYuaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jbGVhckZpbGVJbnB1dCgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG1zZyA9IHNlbGYubXNnRm9sZGVyc05vdEFsbG93ZWQucmVwbGFjZSgne259JywgZm9sZGVycyk7XHJcbiAgICAgICAgICAgIHNlbGYuX2FkZEVycm9yKG1zZyk7XHJcbiAgICAgICAgICAgIHNlbGYuX3NldFZhbGlkYXRpb25FcnJvcigpO1xyXG4gICAgICAgICAgICAkZXJyb3IuZmFkZUluKDgwMCk7XHJcbiAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlZm9sZGVyZXJyb3InLCBbZm9sZGVycywgbXNnXSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfc2hvd1VwbG9hZEVycm9yOiBmdW5jdGlvbiAobXNnLCBwYXJhbXMsIGV2ZW50KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGVycm9yID0gc2VsZi4kZXJyb3JDb250YWluZXIsIGV2ID0gZXZlbnQgfHwgJ2ZpbGV1cGxvYWRlcnJvcicsIGUgPSBwYXJhbXMgJiYgcGFyYW1zLmlkID9cclxuICAgICAgICAgICAgICAgICc8bGkgZGF0YS10aHVtYi1pZD1cIicgKyBwYXJhbXMuaWQgKyAnXCI+JyArIG1zZyArICc8L2xpPicgOiAnPGxpPicgKyBtc2cgKyAnPC9saT4nO1xyXG4gICAgICAgICAgICBpZiAoJGVycm9yLmZpbmQoJ3VsJykubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9hZGRFcnJvcignPHVsPicgKyBlICsgJzwvdWw+Jyk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAkZXJyb3IuZmluZCgndWwnKS5hcHBlbmQoZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGVycm9yLmZhZGVJbig4MDApO1xyXG4gICAgICAgICAgICBzZWxmLl9yYWlzZShldiwgW3BhcmFtcywgbXNnXSk7XHJcbiAgICAgICAgICAgIHNlbGYuX3NldFZhbGlkYXRpb25FcnJvcignZmlsZS1pbnB1dC1uZXcnKTtcclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfc2hvd0Vycm9yOiBmdW5jdGlvbiAobXNnLCBwYXJhbXMsIGV2ZW50KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGVycm9yID0gc2VsZi4kZXJyb3JDb250YWluZXIsIGV2ID0gZXZlbnQgfHwgJ2ZpbGVlcnJvcic7XHJcbiAgICAgICAgICAgIHBhcmFtcyA9IHBhcmFtcyB8fCB7fTtcclxuICAgICAgICAgICAgcGFyYW1zLnJlYWRlciA9IHNlbGYucmVhZGVyO1xyXG4gICAgICAgICAgICBzZWxmLl9hZGRFcnJvcihtc2cpO1xyXG4gICAgICAgICAgICAkZXJyb3IuZmFkZUluKDgwMCk7XHJcbiAgICAgICAgICAgIHNlbGYuX3JhaXNlKGV2LCB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VsZi5fc2V0VmFsaWRhdGlvbkVycm9yKCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcGFyc2VFcnJvcjogZnVuY3Rpb24gKG9wZXJhdGlvbiwganFYSFIsIGVycm9yVGhyb3duLCBmaWxlTmFtZSkge1xyXG4gICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBqcVhIUi5yZXNwb25zZUpTT04gKi9cclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBlcnJNc2cgPSAkLnRyaW0oZXJyb3JUaHJvd24gKyAnJyksIHRleHRQcmUsXHJcbiAgICAgICAgICAgICAgICB0ZXh0ID0ganFYSFIucmVzcG9uc2VKU09OICE9PSB1bmRlZmluZWQgJiYganFYSFIucmVzcG9uc2VKU09OLmVycm9yICE9PSB1bmRlZmluZWQgP1xyXG4gICAgICAgICAgICAgICAgICAgIGpxWEhSLnJlc3BvbnNlSlNPTi5lcnJvciA6IGpxWEhSLnJlc3BvbnNlVGV4dDtcclxuICAgICAgICAgICAgaWYgKHNlbGYuY2FuY2VsbGluZyAmJiBzZWxmLm1zZ1VwbG9hZEFib3J0ZWQpIHtcclxuICAgICAgICAgICAgICAgIGVyck1zZyA9IHNlbGYubXNnVXBsb2FkQWJvcnRlZDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoc2VsZi5zaG93QWpheEVycm9yRGV0YWlscyAmJiB0ZXh0KSB7XHJcbiAgICAgICAgICAgICAgICB0ZXh0ID0gJC50cmltKHRleHQucmVwbGFjZSgvXFxuXFxzKlxcbi9nLCAnXFxuJykpO1xyXG4gICAgICAgICAgICAgICAgdGV4dFByZSA9IHRleHQubGVuZ3RoID8gJzxwcmU+JyArIHRleHQgKyAnPC9wcmU+JyA6ICcnO1xyXG4gICAgICAgICAgICAgICAgZXJyTXNnICs9IGVyck1zZyA/IHRleHRQcmUgOiB0ZXh0O1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICghZXJyTXNnKSB7XHJcbiAgICAgICAgICAgICAgICBlcnJNc2cgPSBzZWxmLm1zZ0FqYXhFcnJvci5yZXBsYWNlKCd7b3BlcmF0aW9ufScsIG9wZXJhdGlvbik7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5jYW5jZWxsaW5nID0gZmFsc2U7XHJcbiAgICAgICAgICAgIHJldHVybiBmaWxlTmFtZSA/ICc8Yj4nICsgZmlsZU5hbWUgKyAnOiA8L2I+JyArIGVyck1zZyA6IGVyck1zZztcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9wYXJzZUZpbGVUeXBlOiBmdW5jdGlvbiAodHlwZSwgbmFtZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGlzVmFsaWQsIHZUeXBlLCBjYXQsIGksIHR5cGVzID0gc2VsZi5hbGxvd2VkUHJldmlld1R5cGVzIHx8IFtdO1xyXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ2FwcGxpY2F0aW9uL3RleHQtcGxhaW4nKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gJ3RleHQnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0eXBlcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY2F0ID0gdHlwZXNbaV07XHJcbiAgICAgICAgICAgICAgICBpc1ZhbGlkID0gc2VsZi5maWxlVHlwZVNldHRpbmdzW2NhdF07XHJcbiAgICAgICAgICAgICAgICB2VHlwZSA9IGlzVmFsaWQodHlwZSwgbmFtZSkgPyBjYXQgOiAnJztcclxuICAgICAgICAgICAgICAgIGlmICghJGguaXNFbXB0eSh2VHlwZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdlR5cGU7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuICdvdGhlcic7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0UHJldmlld0ljb246IGZ1bmN0aW9uIChmbmFtZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGV4dCwgb3V0ID0gbnVsbDtcclxuICAgICAgICAgICAgaWYgKGZuYW1lICYmIGZuYW1lLmluZGV4T2YoJy4nKSA+IC0xKSB7XHJcbiAgICAgICAgICAgICAgICBleHQgPSBmbmFtZS5zcGxpdCgnLicpLnBvcCgpO1xyXG4gICAgICAgICAgICAgICAgaWYgKHNlbGYucHJldmlld0ZpbGVJY29uU2V0dGluZ3MpIHtcclxuICAgICAgICAgICAgICAgICAgICBvdXQgPSBzZWxmLnByZXZpZXdGaWxlSWNvblNldHRpbmdzW2V4dF0gfHwgc2VsZi5wcmV2aWV3RmlsZUljb25TZXR0aW5nc1tleHQudG9Mb3dlckNhc2UoKV0gfHwgbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLnByZXZpZXdGaWxlRXh0U2V0dGluZ3MpIHtcclxuICAgICAgICAgICAgICAgICAgICAkLmVhY2goc2VsZi5wcmV2aWV3RmlsZUV4dFNldHRpbmdzLCBmdW5jdGlvbiAoa2V5LCBmdW5jKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLnByZXZpZXdGaWxlSWNvblNldHRpbmdzW2tleV0gJiYgZnVuYyhleHQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXQgPSBzZWxmLnByZXZpZXdGaWxlSWNvblNldHRpbmdzW2tleV07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL25vaW5zcGVjdGlvbiBVbm5lY2Vzc2FyeVJldHVyblN0YXRlbWVudEpTXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gb3V0O1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3BhcnNlRmlsZVByZXZpZXdJY29uOiBmdW5jdGlvbiAoY29udGVudCwgZm5hbWUpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBpY24gPSBzZWxmLl9nZXRQcmV2aWV3SWNvbihmbmFtZSkgfHwgc2VsZi5wcmV2aWV3RmlsZUljb24sIG91dCA9IGNvbnRlbnQ7XHJcbiAgICAgICAgICAgIGlmIChvdXQuaW5kZXhPZigne3ByZXZpZXdGaWxlSWNvbn0nKSA+IC0xKSB7XHJcbiAgICAgICAgICAgICAgICBvdXQgPSBvdXQuc2V0VG9rZW5zKHsncHJldmlld0ZpbGVJY29uQ2xhc3MnOiBzZWxmLnByZXZpZXdGaWxlSWNvbkNsYXNzLCAncHJldmlld0ZpbGVJY29uJzogaWNufSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIG91dDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9yYWlzZTogZnVuY3Rpb24gKGV2ZW50LCBwYXJhbXMpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBlID0gJC5FdmVudChldmVudCk7XHJcbiAgICAgICAgICAgIGlmIChwYXJhbXMgIT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kZWxlbWVudC50cmlnZ2VyKGUsIHBhcmFtcyk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRlbGVtZW50LnRyaWdnZXIoZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGUuaXNEZWZhdWx0UHJldmVudGVkKCkgfHwgZS5yZXN1bHQgPT09IGZhbHNlKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc3dpdGNoIChldmVudCkge1xyXG4gICAgICAgICAgICAgICAgLy8gaWdub3JlIHRoZXNlIGV2ZW50c1xyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmlsZWJhdGNodXBsb2FkY29tcGxldGUnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmlsZWJhdGNodXBsb2Fkc3VjY2Vzcyc6XHJcbiAgICAgICAgICAgICAgICBjYXNlICdmaWxldXBsb2FkZWQnOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmlsZWNsZWFyJzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2ZpbGVjbGVhcmVkJzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2ZpbGVyZXNldCc6XHJcbiAgICAgICAgICAgICAgICBjYXNlICdmaWxlZXJyb3InOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmlsZWZvbGRlcmVycm9yJzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2ZpbGV1cGxvYWRlcnJvcic6XHJcbiAgICAgICAgICAgICAgICBjYXNlICdmaWxlYmF0Y2h1cGxvYWRlcnJvcic6XHJcbiAgICAgICAgICAgICAgICBjYXNlICdmaWxlZGVsZXRlZXJyb3InOlxyXG4gICAgICAgICAgICAgICAgY2FzZSAnZmlsZWN1c3RvbWVycm9yJzpcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2ZpbGVzdWNjZXNzcmVtb3ZlJzpcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIC8vIHJlY2VpdmUgZGF0YSByZXNwb25zZSB2aWEgYGZpbGVjdXN0b21lcnJvcmAgZXZlbnRgXHJcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghc2VsZi5hamF4QWJvcnRlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmFqYXhBYm9ydGVkID0gZS5yZXN1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1ZScpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgJGJ0bkJvcmQuYWRkQ2xhc3MoJ2FjdGl2ZScpLmF0dHIoJ2FyaWEtcHJlc3NlZCcsICd0cnVlJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCRtb2RhbC5oYXNDbGFzcygnZmlsZS16b29tLWZ1bGxzY3JlZW4nKSkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fbWF4aW1pemVab29tRGlhbG9nKCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaXNGdWxsU2NyZWVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fbWF4aW1pemVab29tRGlhbG9nKCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICRidG5Cb3JkLnJlbW92ZUNsYXNzKCdhY3RpdmUnKS5hdHRyKCdhcmlhLXByZXNzZWQnLCAnZmFsc2UnKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2xpc3RlbjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlbCA9IHNlbGYuJGVsZW1lbnQsICRmb3JtID0gc2VsZi4kZm9ybSwgJGNvbnQgPSBzZWxmLiRjb250YWluZXIsIGZ1bGxTY3JlZW5FdmVudHM7XHJcbiAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJGVsLCAnY2xpY2snLCBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCRlbC5oYXNDbGFzcygnZmlsZS1uby1icm93c2UnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICgkZWwuZGF0YSgnem9uZUNsaWNrZWQnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkZWwuZGF0YSgnem9uZUNsaWNrZWQnLCBmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJGVsLCAnY2hhbmdlJywgJC5wcm94eShzZWxmLl9jaGFuZ2UsIHNlbGYpKTtcclxuICAgICAgICAgICAgaWYgKHNlbGYuc2hvd0Jyb3dzZSkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faGFuZGxlcihzZWxmLiRidG5GaWxlLCAnY2xpY2snLCAkLnByb3h5KHNlbGYuX2Jyb3dzZSwgc2VsZikpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJGNvbnQuZmluZCgnLmZpbGVpbnB1dC1yZW1vdmU6bm90KFtkaXNhYmxlZF0pJyksICdjbGljaycsICQucHJveHkoc2VsZi5jbGVhciwgc2VsZikpO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRjb250LmZpbmQoJy5maWxlaW5wdXQtY2FuY2VsJyksICdjbGljaycsICQucHJveHkoc2VsZi5jYW5jZWwsIHNlbGYpKTtcclxuICAgICAgICAgICAgc2VsZi5faW5pdERyYWdEcm9wKCk7XHJcbiAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJGZvcm0sICdyZXNldCcsICQucHJveHkoc2VsZi5jbGVhciwgc2VsZikpO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRmb3JtLCAnc3VibWl0JywgJC5wcm94eShzZWxmLl9zdWJtaXRGb3JtLCBzZWxmKSk7XHJcbiAgICAgIC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WVudEVsZW1lbnQuY2xpZW50V2lkdGggfHwgZG9jdW1lbnQuYm9keS5jbGllbnRXaWR0aCxcclxuICAgICAgICAgICAgICAgIHNlbGYgPSB0aGlzLCBjb25maWcgPSB3aWR0aCA8IDQwMCA/IChzZWxmLnByZXZpZXdTZXR0aW5nc1NtYWxsIHx8IHNlbGYuZGVmYXVsdHMucHJldmlld1NldHRpbmdzU21hbGwpIDpcclxuICAgICAgICAgICAgICAgIChzZWxmLnByZXZpZXdTZXR0aW5ncyB8fCBzZWxmLmRlZmF1bHRzLnByZXZpZXdTZXR0aW5ncyksIHNlbDtcclxuICAgICAgICAgICAgJC5lYWNoKGNvbmZpZywgZnVuY3Rpb24gKGNhdCwgc2V0dGluZ3MpIHtcclxuICAgICAgICAgICAgICAgIHNlbCA9ICcuZmlsZS1wcmV2aWV3LWZyYW1lIC5maWxlLXByZXZpZXctJyArIGNhdDtcclxuICAgICAgICAgICAgICAgIHNlbGYuJHByZXZpZXcuZmluZChzZWwgKyAnLmt2LXByZXZpZXctZGF0YSwnICsgc2VsICsgJyAua3YtcHJldmlldy1kYXRhJykuY3NzKHNldHRpbmdzKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfc2NhbkRyb3BwZWRJdGVtczogZnVuY3Rpb24gKGl0ZW0sIGZpbGVzLCBwYXRoKSB7XHJcbiAgICAgICAgICAgIHBhdGggPSBwYXRoIHx8ICcnO1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGksIGRpclJlYWRlciwgcmVhZERpciwgZXJyb3JIYW5kbGVyID0gZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2xvZygnRXJyb3Igc2Nhbm5pbmcgZHJvcHBlZCBmaWxlcyEnKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2xvZyhlKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgaWYgKGl0ZW0uaXNGaWxlKSB7XHJcbiAgICAgICAgICAgICAgICBpdGVtLmZpbGUoZnVuY3Rpb24gKGZpbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBmaWxlcy5wdXNoKGZpbGUpO1xyXG4gICAgICAgICAgICAgICAgfSwgZXJyb3JIYW5kbGVyKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlmIChpdGVtLmlzRGlyZWN0b3J5KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZGlyUmVhZGVyID0gaXRlbS5jcmVhdGVSZWFkZXIoKTtcclxuICAgICAgICAgICAgICAgICAgICByZWFkRGlyID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkaXJSZWFkZXIucmVhZEVudHJpZXMoZnVuY3Rpb24gKGVudHJpZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyaWVzICYmIGVudHJpZXMubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBlbnRyaWVzLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NjYW5Ecm9wcGVkSXRlbXMoZW50cmllc1tpXSwgZmlsZXMsIHBhdGggKyBpdGVtLm5hbWUgKyAnLycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWN1cnNpdmVseSBjYWxsIHJlYWREaXIoKSBhZ2Fpbiwgc2luY2UgYnJvd3NlciBjYW4gb25seSBoYW5kbGUgZmlyc3QgMTAwIGVudHJpZXMuXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZERpcigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGVycm9ySGFuZGxlcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgICAgICByZWFkRGlyKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdERyYWdEcm9wOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJHpvbmUgPSBzZWxmLiRkcm9wWm9uZTtcclxuICAgICAgICAgICAgaWYgKHNlbGYuZHJvcFpvbmVFbmFibGVkICYmIHNlbGYuc2hvd1ByZXZpZXcpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJHpvbmUsICdkcmFnZW50ZXIgZHJhZ292ZXInLCAkLnByb3h5KHNlbGYuX3pvbmVEcmFnRW50ZXIsIHNlbGYpKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJHpvbmUsICdkcmFnbGVhdmUnLCAkLnByb3h5KHNlbGYuX3pvbmVEcmFnTGVhdmUsIHNlbGYpKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJHpvbmUsICdkcm9wJywgJC5wcm94eShzZWxmLl96b25lRHJvcCwgc2VsZikpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faGFuZGxlcigkKGRvY3VtZW50KSwgJ2RyYWdlbnRlciBkcmFnb3ZlciBkcm9wJywgc2VsZi5fem9uZURyYWdEcm9wSW5pdCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF96b25lRHJhZ0Ryb3BJbml0OiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpO1xyXG4gICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgfSxc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TtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRlbC50cmlnZ2VyKCdjaGFuZ2UnICsgc2VsZi5uYW1lc3BhY2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCAxMCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fY2hhbmdlKGUsIGZpbGVzKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi4kZHJvcFpvbmUucmVtb3ZlQ2xhc3MoJ2ZpbGUtaGlnaGxpZ2h0ZWQnKTtcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgaWYgKHNlbGYuaXNEaXNhYmxlZCB8fCAkaC5pc0VtcHR5KGZpbGVzKSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5fcmFpc2UoJ2ZpbGVEcmFnRHJvcCcsIHsnc291cmNlRXZlbnQnOiBlLCAnZmlsZXMnOiBmaWxlc30pKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGZvbGRlcnMgPiAwKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIXNlbGYuaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2hvd0ZvbGRlckVycm9yKGZvbGRlcnMpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGZpbGVzID0gW107XHJcbiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaXRlbXMubGVuZ3RoOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgaXRlbSA9IGl0ZW1zW2ldLndlYmtpdEdldEFzRW50cnkoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zY2FuRHJvcHBlZEl0ZW1zKGl0ZW0sIGZpbGVzKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzRmlsZXMoKTtcclxuICAgICAgICAgICAgICAgIH0sIDUwMCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzRmlsZXMoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3VwbG9hZENsaWNrOiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRidG4gPSBzZWxmLiRjb250YWluZXIuZmluZCgnLmZpbGVpbnB1dC11cGxvYWQnKSwgJGZvcm0sXHJcbiAgICAgICAgICAgICAgICBpc0VuYWJsZWQgPSAhJGJ0bi5oYXNDbGFzcygnZGlzYWJsZWQnKSAmJiAkaC5pc0VtcHR5KCRidG4uYXR0cignZGlzYWJsZWQnKSk7XHJcbiAgICAgICAgICAgIGlmIChlICYmIGUuaXNEZWZhdWx0UHJldmVudGVkKCkpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoIXNlbGYuaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoaXNFbmFibGVkICYmICRidG4uYXR0cigndHlwZScpICE9PSAnc3VibWl0Jykge1xyXG4gICAgICAgICAgICAgICAgICAgICRmb3JtID0gJGJ0bi5jbG9zZXN0KCdmb3JtJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy8gZG93bmdyYWRlIHRvIG5vcm1hbCBmb3JtIHN1Ym1pdCBpZiBwb3NzaWJsZVxyXG4gICAgICAgICAgICAgICAgICAgIGlmICgkZm9ybS5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGZvcm0udHJpZ2dlcignc3VibWl0Jyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XHJcbiAgICAgICAgICAgIGlmIChpc0VuYWJsZWQpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9zdWJtaXRGb3JtOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIHNlbGYuX2lzRmlsZVNlbGVjdGlvblZhbGlkKCkgJiYgIXNlbGYuX2Fib3J0KHt9KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9jbGVhclByZXZpZXc6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkcCA9IHNlbGYuJHByZXZpZXcsXHJcbiAgICAgICAgICAgICAgICAkdGh1bWJzID0gc2VsZi5zaG93VXBsb2FkZWRUaHVtYnMgPyBzZWxmLmdldEZyYW1lcygnOm5vdCguZmlsZS1wcmV2aWV3LXN1Y2Nlc3MpJykgOiBzZWxmLmdldEZyYW1lcygpO1xyXG4gICAgICAgICAgICAkdGh1bWJzLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyk7XHJcbiAgICAgICAgICAgICAgICAkdGh1bWIucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgICAgICAkaC5jbGVhblpvb21DYWNoZSgkcC5maW5kKCcjem9vbS0nICsgJHRodW1iLmF0dHIoJ2lkJykpKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5nZXRGcmFtZXMoKS5sZW5ndGggfHwgIXNlbGYuc2hvd1ByZXZpZXcpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Jlc2V0VXBsb2FkKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fdmFsaWRhdGVEZWZhdWx0UHJldmlldygpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRTb3J0YWJsZTogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlbCA9IHNlbGYuJHByZXZpZXcsIHNldHRpbmdzLCBzZWxlY3RvciA9ICcuJyArICRoLlNPUlRfQ1NTLFxyXG4gICAgICAgICAgICAgICAgcmV2ID0gc2VsZi5yZXZlcnNlUHJldmlld09yZGVyO1xyXG4gICAgICAgICAgICBpZiAoIXdpbmRvdy5LdlNvcnRhYmxlIHx8ICRlbC5maW5kKHNlbGVjdG9yKS5sZW5ndGggPT09IDApIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAvL25vaW5zcGVjdGlvbiBKU1VudXNlZEdsb2JhbFN5bWJvbHNcclxuICAgICAgICAgICAgc2V0dGluZ3MgPSB7XHJcbiAgICAgICAgICAgICAgICBoYW5kbGU6ICcuZHJhZy1oYW5kbGUtaW5pdCcsXHJcbiAgICAgICAgICAgICAgICBkYXRhSWRBdHRyOiAnZGF0YS1wcmV2aWV3LWlkJyxcclxuICAgICAgICAgICAgICAgIHNjcm9sbDogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICBkcmFnZ2FibGU6IHNlbGVjdG9yLFxyXG4gICAgICAgICAgICAgICAgb25Tb3J0OiBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBvbGRJbmRleCA9IGUub2xkSW5kZXgsIG5ld0luZGV4ID0gZS5uZXdJbmRleCwgaSA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5pbml0aWFsUHJldmlldyA9ICRoLm1vdmVBcnJheShzZWxmLmluaXRpYWxQcmV2aWV3LCBvbGRJbmRleCwgbmV3SW5kZXgsIHJldik7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5pbml0aWFsUHJldmlld0NvbmZpZyA9ICRoLm1vdmVBcnJheShzZWxmLmluaXRpYWxQcmV2aWV3Q29uZmlnLCBvbGRJbmRleCwgbmV3SW5kZXgsIHJldik7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuaW5pdCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuZ2V0RnJhbWVzKCcuZmlsZS1wcmV2aWV3LWluaXRpYWwnKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS5hdHRyKCdkYXRhLWZpbGVpbmRleCcsICdpbml0XycgKyBpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaSsrO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlc29ydGVkJywge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwcmV2aWV3SWQ6ICQoZS5pdGVtKS5hdHRyKCdpZCcpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAnb2xkSW5kZXgnOiBvbGRJbmRleCxcclxuICAgICAgICAgICAgICAgICAgICAgICAgJ25ld0luZGV4JzogbmV3SW5kZXgsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YWNrOiBzZWxmLmluaXRpYWxQcmV2aWV3Q29uZmlnXHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGlmICgkZWwuZGF0YSgna3Zzb3J0YWJsZScpKSB7XHJcbiAgICAgICAgICAgICAgICAkZWwua3Zzb3J0YWJsZSgnZGVzdHJveScpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICQuZXh0ZW5kKHRydWUsIHNldHRpbmdzLCBzZWxmLmZpbGVBY3Rpb25TZXR0aW5ncy5kcmFnU2V0dGluZ3MpO1xyXG4gICAgICAgICAgICAkZWwua3Zzb3J0YWJsZShzZXR0aW5ncyk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfc2V0UHJldmlld0NvbnRlbnQ6IGZ1bmN0aW9uIChjb250ZW50KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgc2VsZi4kcHJldmlldy5odG1sKGNvbnRlbnQpO1xyXG4gICAgICAgICAgICBzZWxmLl9hdXRvRml0Q29udGVudCgpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRQcmV2aWV3OiBmdW5jdGlvbiAoaXNJbml0KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgY2FwID0gc2VsZi5pbml0aWFsQ2FwdGlvbiB8fCAnJywgb3V0O1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYucHJldmlld0NhY2hlLmNvdW50KCkpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyUHJldmlldygpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGlzSW5pdCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldENhcHRpb24oY2FwKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdENhcHRpb24oKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBvdXQgPSBzZWxmLnByZXZpZXdDYWNoZS5vdXQoKTtcclxuICAgICAgICAgICAgY2FwID0gaXNJbml0ICYmIHNlbGYuaW5pdGlhbENhcHRpb24gPyBzZWxmLmluaXRpYWxDYXB0aW9uIDogb3V0LmNhcHRpb247XHJcbiAgICAgICAgICAgIHNlbGYuX3NldFByZXZpZXdDb250ZW50KG91dC5jb250ZW50KTtcclxuICAgICAgICAgICAgc2VsZi5fc2V0SW5pdFRodW1iQXR0cigpO1xyXG4gICAgICAgICAgICBzZWxmLl9zZXRDYXB0aW9uKGNhcCk7XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRTb3J0YWJsZSgpO1xyXG4gICAgICAgICAgICBpZiAoISRoLmlzRW1wdHkob3V0LmNvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRjb250YWluZXIucmVtb3ZlQ2xhc3MoJ2ZpbGUtaW5wdXQtbmV3Jyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9nZXRab29tQnV0dG9uOiBmdW5jdGlvbiAodHlwZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGxhYmVsID0gc2VsZi5wcmV2aWV3Wm9vbUJ1dHRvbkljb25zW3R5cGVdLCBjc3MgPSBzZWxmLnByZXZpZXdab29tQnV0dG9uQ2xhc3Nlc1t0eXBlXSxcclxuICAgICAgICAgICAgICAgIHRpdGxlID0gJyB0aXRsZT1cIicgKyAoc2VsZi5wcmV2aWV3Wm9vbUJ1dHRvblRpdGxlc1t0eXBlXSB8fCAnJykgKyAnXCIgJyxcclxuICAgICAgICAgICAgICAgIHBhcmFtcyA9IHRpdGxlICsgKHR5cGUgPT09ICdjbG9zZScgPyAnIGRhdGEtZGlzbWlzcz1cIm1vZGFsXCIgYXJpYS1oaWRkZW49XCJ0cnVlXCInIDogJycpO1xyXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ2Z1bGxzY3JlZW4nIHx8IHR5cGUgPT09ICdib3JkZXJsZXNzJyB8fCB0eXBlID09PSAndG9nZ2xlaGVhZGVyJykge1xyXG4gICAgICAgICAgICAgICAgcGFyYW1zICs9ICcgZGF0YS10b2dnbGU9XCJidXR0b25cIiBhcmlhLXByZXNzZWQ9XCJmYWxzZVwiIGF1dG9jb21wbGV0ZT1cIm9mZlwiJztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gJzxidXR0b24gdHlwZT1cImJ1dHRvblwiIGNsYXNzPVwiJyArIGNzcyArICcgYnRuLScgKyB0eXBlICsgJ1wiJyArIHBhcmFtcyArICc+JyArIGxhYmVsICsgJzwvYnV0dG9uPic7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0TW9kYWxDb250ZW50OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdtb2RhbCcpLnNldFRva2Vucyh7XHJcbiAgICAgICAgICAgICAgICAncnRsJzogc2VsZi5ydGwgPyAnIGt2LXJ0bCcgOiAnJyxcclxuICAgICAgICAgICAgICAgICd6b29tRnJhbWVDbGFzcyc6IHNlbGYuZnJhbWVDbGFzcyxcclxuICAgICAgICAgICAgICAgICdoZWFkaW5nJzogc2VsZi5tc2dab29tTW9kYWxIZWFkaW5nLFxyXG4gICAgICAgICAgICAgICAgJ3ByZXYnOiBzZWxmLl9nZXRab29tQnV0dG9uKCdwcmV2JyksXHJcbiAgICAgICAgICAgICAgICAnbmV4dCc6IHNlbGYuX2dldFpvb21CdXR0b24oJ25leHQnKSxcclxuICAgICAgICAgICAgICAgICd0b2dnbGVoZWFkZXInOiBzZWxmLl9nZXRab29tQnV0dG9uKCd0b2dnbGVoZWFkZXInKSxcclxuICAgICAgICAgICAgICAgICdmdWxsc2NyZWVuJzogc2VsZi5fZ2V0Wm9vbUJ1dHRvbignZnVsbHNjcmVlbicpLFxyXG4gICAgICAgICAgICAgICAgJ2JvcmRlcmxlc3MnOiBzZWxmLl9nZXRab29tQnV0dG9uKCdib3JkZXJsZXNzJyksXHJcbiAgICAgICAgICAgICAgICAnY2xvc2UnOiBzZWxmLl9nZXRab29tQnV0dG9uKCdjbG9zZScpXHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2xpc3Rlbk1vZGFsRXZlbnQ6IGZ1bmN0aW9uIChldmVudCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRtb2RhbCA9IHNlbGYuJG1vZGFsLCBnZXRQYXJhbXMgPSBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgICAgICAgICBzb3VyY2VFdmVudDogZSxcclxuICAgICAgICAgICAgICAgICAgICBwcmV2aWV3SWQ6ICRtb2RhbC5kYXRhKCdwcmV2aWV3SWQnKSxcclxuICAgICAgICAgICAgICAgICAgICBtb2RhbDogJG1vZGFsXHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAkbW9kYWwub24oZXZlbnQgKyAnLmJzLm1vZGFsJywgZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgICAgIHZhciAkYnRuRnVsbCA9ICRtb2RhbC5maW5kKCcuYnRuLWZ1bGxzY3JlZW4nKSwgJGJ0bkJvcmQgPSAkbW9kYWwuZmluZCgnLmJ0bi1ib3JkZXJsZXNzJyk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZXpvb20nICsgZXZlbnQsIGdldFBhcmFtcyhlKSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoZXZlbnQgPT09ICdzaG93bicpIHtcclxuICAgICAgICAgICAgICAgICAgICAkYnRuQm9yZC5yZW1vdmVDbGFzcygnYWN0aXZlJykuYXR0cignYXJpYS1wcmVzc2VkJywgJ2ZhbHNlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGJ0bkZ1bGwucmVtb3ZlQ2xhc3MoJ2FjdGl2ZScpLmF0dHIoJ2FyaWEtcHJlc3NlZCcsICdmYWxzZScpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICgkbW9kYWwuaGFzQ2xhc3MoJ2ZpbGUtem9vbS1mdWxsc2NyZWVuJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fbWF4aW1pemVab29tRGlhbG9nKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkaC5jaGVja0Z1bGxTY3JlZW4oKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkZ1bGwuYWRkQ2xhc3MoJ2FjdGl2ZScpLmF0dHIoJ2FyaWEtcHJlc3NlZCcsICd0cnVlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkYnRuQm9yZC5hZGRDbGFzcygnYWN0aXZlJykuYXR0cignYXJpYS1wcmVzc2VkJywgJ3RydWUnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdFpvb206IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZGlhbG9nLCBtb2RhbE1haW4gPSBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgnbW9kYWxNYWluJyksIG1vZGFsSWQgPSAnIycgKyAkaC5NT0RBTF9JRDtcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi4kbW9kYWwgPSAkKG1vZGFsSWQpO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuJG1vZGFsIHx8ICFzZWxmLiRtb2RhbC5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICRkaWFsb2cgPSAkKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpKS5odG1sKG1vZGFsTWFpbikuaW5zZXJ0QWZ0ZXIoc2VsZi4kY29udGFpbmVyKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuJG1vZGFsID0gJChtb2RhbElkKS5pbnNlcnRCZWZvcmUoJGRpYWxvZyk7XHJcbiAgICAgICAgICAgICAgICAkZGlhbG9nLnJlbW92ZSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRoLmluaXRNb2RhbChzZWxmLiRtb2RhbCk7XHJcbiAgICAgICAgICAgIHNlbGYuJG1vZGFsLmh0bWwoc2VsZi5fZ2V0TW9kYWxDb250ZW50KCkpO1xyXG4gICAgICAgICAgICAkLmVhY2goJGguTU9EQUxfRVZFTlRTLCBmdW5jdGlvbiAoa2V5LCBldmVudCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fbGlzdGVuTW9kYWxFdmVudChldmVudCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRab29tQnV0dG9uczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHByZXZpZXdJZCA9IHNlbGYuJG1vZGFsLmRhdGEoJ3ByZXZpZXdJZCcpIHx8ICcnLCAkZmlyc3QsICRsYXN0LFxyXG4gICAgICAgICAgICAgICAgdGh1bWJzID0gc2VsZi5nZXRGcmFtZXMoKS50b0FycmF5KCksIGxlbiA9IHRodW1icy5sZW5ndGgsICRwcmV2ID0gc2VsZi4kbW9kYWwuZmluZCgnLmJ0bi1wcmV2JyksXHJcbiAgICAgICAgICAgICAgICAkbmV4dCA9IHNlbGYuJG1vZGFsLmZpbmQoJy5idG4tbmV4dCcpO1xyXG4gICAgICAgICAgICBpZiAodGh1bWJzLmxlbmd0aCA8IDIpIHtcclxuICAgICAgICAgICAgICAgICRwcmV2LmhpZGUoKTtcclxuICAgICAgICAgICAgICAgICRuZXh0LmhpZGUoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICRwcmV2LnNob3coKTtcclxuICAgICAgICAgICAgICAgICRuZXh0LnNob3coKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoIWxlbikge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRmaXJzdCA9ICQodGh1bWJzWzBdKTtcclxuICAgICAgICAgICAgJGxhc3QgPSAkKHRodW1ic1tsZW4gLSAxXSk7XHJcbiAgICAgICAgICAgICRwcmV2LnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgICRuZXh0LnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgIGlmICgkZmlyc3QubGVuZ3RoICYmICRmaXJzdC5hdHRyKCdpZCcpID09PSBwcmV2aWV3SWQpIHtcclxuICAgICAgICAgICAgICAgICRwcmV2LmF0dHIoJ2Rpc2FibGVkJywgdHJ1ZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCRsYXN0Lmxlbmd0aCAmJiAkbGFzdC5hdHRyKCdpZCcpID09PSBwcmV2aWV3SWQpIHtcclxuICAgICAgICAgICAgICAgICRuZXh0LmF0dHIoJ2Rpc2FibGVkJywgdHJ1ZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9tYXhpbWl6ZVpvb21EaWFsb2c6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkbW9kYWwgPSBzZWxmLiRtb2RhbCwgJGhlYWQgPSAkbW9kYWwuZmluZCgnLm1vZGFsLWhlYWRlcjp2aXNpYmxlJyksXHJcbiAgICAgICAgICAgICAgICAkZm9vdCA9ICRtb2RhbC5maW5kKCcubW9kYWwtZm9vdGVyOnZpc2libGUnKSwgJGJvZHkgPSAkbW9kYWwuZmluZCgnLm1vZGFsLWJvZHknKSxcclxuICAgICAgICAgICAgICAgIGggPSAkKHdpbmRvdykuaGVpZ2h0KCksIGRpZmYgPSAwO1xyXG4gICAgICAgICAgICAkbW9kYWwuYWRkQ2xhc3MoJ2ZpbGUtem9vbS1mdWxsc2NyZWVuJyk7XHJcbiAgICAgICAgICAgIGlmICgkaGVhZCAmJiAkaGVhZC5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgIGggLT0gJGhlYWQub3V0ZXJIZWlnaHQodHJ1ZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCRmb290ICYmICRmb290Lmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgaCAtPSAkZm9vdC5vdXRlckhlaWdodCh0cnVlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoJGJvZHkgJiYgJGJvZHkubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICBkaWZmID0gJGJvZHkub3V0ZXJIZWlnaHQodHJ1ZSkgLSAkYm9keS5oZWlnaHQoKTtcclxuICAgICAgICAgICAgICAgIGggLT0gZGlmZjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkbW9kYWwuZmluZCgnLmt2LXpvb20tYm9keScpLmhlaWdodChoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9yZXNpemVab29tRGlhbG9nOiBmdW5jdGlvbiAoZnVsbFNjcmVlbikge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRtb2RhbCA9IHNlbGYuJG1vZGFsLCAkYnRuRnVsbCA9ICRtb2RhbC5maW5kKCcuYnRuLWZ1bGxzY3JlZW4nKSxcclxuICAgICAgICAgICAgICAgICRidG5Cb3JkID0gJG1vZGFsLmZpbmQoJy5idG4tYm9yZGVybGVzcycpO1xyXG4gICAgICAgICAgICBpZiAoJG1vZGFsLmhhc0NsYXNzKCdmaWxlLXpvb20tZnVsbHNjcmVlbicpKSB7XHJcbiAgICAgICAgICAgICAgICAkaC50b2dnbGVGdWxsU2NyZWVuKGZhbHNlKTtcclxuICAgICAgICAgICAgICAgIGlmICghZnVsbFNjcmVlbikge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghJGJ0bkZ1bGwuaGFzQ2xhc3MoJ2FjdGl2ZScpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRtb2RhbC5yZW1vdmVDbGFzcygnZmlsZS16b29tLWZ1bGxzY3JlZW4nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi4kbW9kYWwuZmluZCgnLmt2LXpvb20tYm9keScpLmNzcygnaGVpZ2h0Jywgc2VsZi56b29tTW9kYWxIZWlnaHQpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRidG5GdWxsLnJlbW92ZUNsYXNzKCdhY3RpdmUnKS5hdHRyKCdhcmlhLXByZXNzZWQnLCAnZmFsc2UnKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghJGJ0bkZ1bGwuaGFzQ2xhc3MoJ2FjdGl2ZScpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRtb2RhbC5yZW1vdmVDbGFzcygnZmlsZS16b29tLWZ1bGxzY3JlZW4nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmVzaXplWm9vbURpYWxvZyh0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRidG5Cb3JkLmhhc0NsYXNzKCdhY3RpdmUnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkJvcmQucmVtb3ZlQ2xhc3MoJ2FjdGl2ZScpLmF0dHIoJ2FyaWEtcHJlc3NlZCcsICdmYWxzZScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFmdWxsU2NyZWVuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fbWF4aW1pemVab29tRGlhbG9nKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgJGgudG9nZ2xlRnVsbFNjcmVlbih0cnVlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkbW9kYWwuZm9jdXMoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9zZXRab29tQ29udGVudDogZnVuY3Rpb24gKCRmcmFtZSwgYW5pbWF0ZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRjb250ZW50LCB0bXBsdCwgYm9keSwgdGl0bGUsICRib2R5LCAkZGF0YUVsLCBjb25maWcsIHByZXZpZXdJZCA9ICRmcmFtZS5hdHRyKCdpZCcpLFxyXG4gICAgICAgICAgICAgICAgJHpvb21QcmV2aWV3ID0gc2VsZi4kcHJldmlldy5maW5kKCcjem9vbS0nICsgcHJldmlld0lkKSwgJG1vZGFsID0gc2VsZi4kbW9kYWwsICR0bXAsXHJcbiAgICAgICA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KCRib2R5KTtcclxuICAgICAgICAgICAgICAgICRib2R5Lmh0bWwoYm9keSkuaGlkZSgpO1xyXG4gICAgICAgICAgICAgICAgJHRtcC5mYWRlT3V0KCdmYXN0JywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICRib2R5LmZhZGVJbignZmFzdCcsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGJvZHkucmVtb3ZlQ2xhc3MoJ2ZpbGUtdGh1bWItbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICR0bXAucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICRib2R5Lmh0bWwoYm9keSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgY29uZmlnID0gc2VsZi5wcmV2aWV3Wm9vbVNldHRpbmdzW3RtcGx0XTtcclxuICAgICAgICAgICAgaWYgKGNvbmZpZykge1xyXG4gICAgICAgICAgICAgICAgJGRhdGFFbCA9ICRib2R5LmZpbmQoJy5rdi1wcmV2aWV3LWRhdGEnKTtcclxuICAgICAgICAgICAgICAgICRoLmFkZENzcygkZGF0YUVsLCAnZmlsZS16b29tLWRldGFpbCcpO1xyXG4gICAgICAgICAgICAgICAgJC5lYWNoKGNvbmZpZywgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcclxuICAgICAgICAgICAgICAgICAgICAkZGF0YUVsLmNzcyhrZXksIHZhbHVlKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoKCRkYXRhRWwuYXR0cignd2lkdGgnKSAmJiBrZXkgPT09ICd3aWR0aCcpIHx8ICgkZGF0YUVsLmF0dHIoJ2hlaWdodCcpICYmIGtleSA9PT0gJ2hlaWdodCcpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRkYXRhRWwucmVtb3ZlQXR0cihrZXkpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRtb2RhbC5kYXRhKCdwcmV2aWV3SWQnLCBwcmV2aWV3SWQpO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRtb2RhbC5maW5kKCcuYnRuLXByZXYnKSwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fem9vbVNsaWRlU2hvdygncHJldicsIHByZXZpZXdJZCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRtb2RhbC5maW5kKCcuYnRuLW5leHQnKSwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fem9vbVNsaWRlU2hvdygnbmV4dCcsIHByZXZpZXdJZCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRidG5GdWxsLCAnY2xpY2snLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yZXNpemVab29tRGlhbG9nKHRydWUpO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgc2VsZi5faGFuZGxlcigkYnRuQm9yZCwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fcmVzaXplWm9vbURpYWxvZyhmYWxzZSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRidG5Ub2doLCAnY2xpY2snLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgJGhlYWRlciA9ICRtb2RhbC5maW5kKCcubW9kYWwtaGVhZGVyJyksICRmbG9hdEJhciA9ICRtb2RhbC5maW5kKCcubW9kYWwtYm9keSAuZmxvYXRpbmctYnV0dG9ucycpLFxyXG4gICAgICAgICAgICAgICAgICAgIGh0LCAkYWN0aW9ucyA9ICRoZWFkZXIuZmluZCgnLmt2LXpvb20tYWN0aW9ucycpLCByZXNpemUgPSBmdW5jdGlvbiAoaGVpZ2h0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkYm9keSA9IHNlbGYuJG1vZGFsLmZpbmQoJy5rdi16b29tLWJvZHknKSwgaCA9IHNlbGYuem9vbU1vZGFsSGVpZ2h0O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoJG1vZGFsLmhhc0NsYXNzKCdmaWxlLXpvb20tZnVsbHNjcmVlbicpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoID0gJGJvZHkub3V0ZXJIZWlnaHQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWhlaWdodCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGggPSBoIC0gJGhlYWRlci5vdXRlckhlaWdodCh0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAkYm9keS5jc3MoJ2hlaWdodCcsIGhlaWdodCA/IGggKyBoZWlnaHQgOiBoKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgaWYgKCRoZWFkZXIuaXMoJzp2aXNpYmxlJykpIHtcclxuICAgICAgICAgICAgICAgICAgICBodCA9ICRoZWFkZXIub3V0ZXJIZWlnaHQodHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGhlYWRlci5zbGlkZVVwKCdzbG93JywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkYWN0aW9ucy5maW5kKCcuYnRuJykuYXBwZW5kVG8oJGZsb2F0QmFyKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzaXplKGh0KTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgJGZsb2F0QmFyLmZpbmQoJy5idG4nKS5hcHBlbmRUbygkYWN0aW9ucyk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGhlYWRlci5zbGlkZURvd24oJ3Nsb3cnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2l6ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgJG1vZGFsLmZvY3VzKCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRtb2RhbCwgJ2tleWRvd24nLCBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgdmFyIGtleSA9IGUud2hpY2ggfHwgZS5rZXlDb2RlLCAkcHJldiA9ICQodGhpcykuZmluZCgnLmJ0bi1wcmV2JyksICRuZXh0ID0gJCh0aGlzKS5maW5kKCcuYnRuLW5leHQnKSxcclxuICAgICAgICAgICAgICAgICAgICB2SWQgPSAkKHRoaXMpLmRhdGEoJ3ByZXZpZXdJZCcpLCB2UHJldktleSA9IHNlbGYucnRsID8gMzkgOiAzNywgdk5leHRLZXkgPSBzZWxmLnJ0bCA/IDM3IDogMzk7XHJcbiAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSB2UHJldktleSAmJiAkcHJldi5sZW5ndGggJiYgISRwcmV2LmF0dHIoJ2Rpc2FibGVkJykpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl96b29tU2xpZGVTaG93KCdwcmV2JywgdklkKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChrZXkgPT09IHZOZXh0S2V5ICYmICRuZXh0Lmxlbmd0aCAmJiAhJG5leHQuYXR0cignZGlzYWJsZWQnKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3pvb21TbGlkZVNob3coJ25leHQnLCB2SWQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF96b29tUHJldmlldzogZnVuY3Rpb24gKCRidG4pIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZnJhbWUsICRtb2RhbCA9IHNlbGYuJG1vZGFsO1xyXG4gICAgICAgICAgICBpZiAoISRidG4ubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICB0aHJvdyAnQ2Fubm90IHpvb20gdG8gZGV0YWlsZWQgcHJldmlldyEnO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRoLmluaXRNb2RhbCgkbW9kYWwpO1xyXG4gICAgICAgICAgICAkbW9kYWwuaHRtbChzZWxmLl9nZXRNb2RhbENvbnRlbnQoKSk7XHJcbiAgICAgICAgICAgICRmcmFtZSA9ICRidG4uY2xvc2VzdCgkaC5GUkFNRVMpO1xyXG4gICAgICAgICAgICBzZWxmLl9zZXRab29tQ29udGVudCgkZnJhbWUpO1xyXG4gICAgICAgICAgICAkbW9kYWwubW9kYWwoJ3Nob3cnKTtcclxuICAgICAgICAgICAgc2VsZi5faW5pdFpvb21CdXR0b25zKCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfem9vbVNsaWRlU2hvdzogZnVuY3Rpb24gKGRpciwgcHJldmlld0lkKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGJ0biA9IHNlbGYuJG1vZGFsLmZpbmQoJy5rdi16b29tLWFjdGlvbnMgLmJ0bi0nICsgZGlyKSwgJHRhcmdGcmFtZSwgaSxcclxuICAgICAgICAgICAgICAgIHRodW1icyA9IHNlbGYuZ2V0RnJhbWVzKCkudG9BcnJheSgpLCBsZW4gPSB0aHVtYnMubGVuZ3RoLCBvdXQ7XHJcbiAgICAgICAgICAgIGlmICgkYnRuLmF0dHIoJ2Rpc2FibGVkJykpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgIGlmICgkKHRodW1ic1tpXSkuYXR0cignaWQnKSA9PT0gcHJldmlld0lkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgb3V0ID0gZGlyID09PSAncHJldicgPyBpIC0gMSA6IGkgKyAxO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChvdXQgPCAwIHx8IG91dCA+PSBsZW4gfHwgIXRodW1ic1tvdXRdKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJHRhcmdGcmFtZSA9ICQodGh1bWJzW291dF0pO1xyXG4gICAgICAgICAgICBpZiAoJHRhcmdGcmFtZS5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldFpvb21Db250ZW50KCR0YXJnRnJhbWUsIHRydWUpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRab29tQnV0dG9ucygpO1xyXG4gICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZXpvb20nICsgZGlyLCB7J3ByZXZpZXdJZCc6IHByZXZpZXdJZCwgbW9kYWw6IHNlbGYuJG1vZGFsfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdFpvb21CdXR0b246IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBzZWxmLiRwcmV2aWV3LmZpbmQoJy5rdi1maWxlLXpvb20nKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHZhciAkZWwgPSAkKHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faGFuZGxlcigkZWwsICdjbGljaycsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl96b29tUHJldmlldygkZWwpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2lucHV0RmlsZUNvdW50OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHJldHVybiB0aGlzLiRlbGVtZW50LmdldCgwKS5maWxlcy5sZW5ndGg7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVmcmVzaFByZXZpZXc6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBmaWxlcztcclxuICAgICAgICAgICAgaWYgKCghc2VsZi5faW5wdXRGaWxlQ291bnQoKSAmJiAhc2VsZi5pc0FqYXhVcGxvYWQpIHx8ICFzZWxmLnNob3dQcmV2aWV3IHx8ICFzZWxmLmlzUHJldmlld2FibGUpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoc2VsZi5pc0FqYXhVcGxvYWQpIHtcclxuICAgICAgICAgICAgICAgIGZpbGVzID0gc2VsZi5nZXRGaWxlU3RhY2soKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuZmlsZXN0YWNrID0gW107XHJcbiAgICAgICAgICAgICAgICBpZiAoZmlsZXMubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fY2xlYXJGaWxlSW5wdXQoKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZmlsZXMgPSBzZWxmLiRlbGVtZW50LmdldCgwKS5maWxlcztcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGZpbGVzID0gc2VsZi4kZWxlbWVudC5nZXQoMCkuZmlsZXM7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGZpbGVzICYmIGZpbGVzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5yZWFkRmlsZXMoZmlsZXMpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fc2V0RmlsZURyb3Bab25lVGl0bGUoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2NsZWFyT2JqZWN0czogZnVuY3Rpb24gKCRlbCkge1xyXG4gICAgICAgICAgICAkZWwuZmluZCgndmlkZW8gYXVkaW8nKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMucGF1c2UoKTtcclxuICAgICAgICAgICAgICAgICQodGhpcykucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAkZWwuZmluZCgnaW1nIG9iamVjdCBkaXYnKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICQodGhpcykucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2NsZWFyRmlsZUlucHV0OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGVsID0gc2VsZi4kZWxlbWVudCwgJHNyY0ZybSwgJHRtcEZybSwgJHRtcEVsO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuX2lucHV0RmlsZUNvdW50KCkpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkc3JjRnJtID0gJGVsLmNsb3Nlc3QoJ2Zvcm0nKTtcclxuICAgICAgICAgICAgJHRtcEZybSA9ICQoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZm9ybScpKTtcclxuICAgICAgICAgICAgJHRtcEVsID0gJChkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKSk7XHJcbiAgICAgICAgICAgICRlbC5iZWZvcmUoJHRtcEVsKTtcclxuICAgICAgICAgICAgaWYgKCRzcmNGcm0ubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAkc3JjRnJtLmFmdGVyKCR0bXBGcm0pO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgJHRtcEVsLmFmdGVyKCR0bXBGcm0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICR0bXBGcm0uYXBwZW5kKCRlbCkudHJpZ2dlcigncmVzZXQnKTtcclxuICAgICAgICAgICAgJHRtcEVsLmJlZm9yZSgkZWwpLnJlbW92ZSgpO1xyXG4gICAgICAgICAgICAkdG1wRnJtLnJlbW92ZSgpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3Jlc2V0VXBsb2FkOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgc2VsZi51cGxvYWRDYWNoZSA9IHtjb250ZW50OiBbXSwgY29uZmlnOiBbXSwgdGFnczogW10sIGFwcGVuZDogdHJ1ZX07XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkQ291bnQgPSAwO1xyXG4gICAgICAgICAgICBzZWxmLnVwbG9hZFN0YXR1cyA9IHt9O1xyXG4gICAgICAgICAgICBzZWxmLnVwbG9hZExvZyA9IFtdO1xyXG4gICAgICAgICAgICBzZWxmLnVwbG9hZEFzeW5jQ291bnQgPSAwO1xyXG4gICAgICAgICAgICBzZWxmLmxvYWRlZEltYWdlcyA9IFtdO1xyXG4gICAgICAgICAgICBzZWxmLnRvdGFsSW1hZ2VzQ291bnQgPSAwO1xyXG4gICAgICAgICAgICBzZWxmLiRidG5VcGxvYWQucmVtb3ZlQXR0cignZGlzYWJsZWQnKTtcclxuICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMCk7XHJcbiAgICAgICAgICAgIHNlbGYuJHByb2dyZXNzLmhpZGUoKTtcclxuICAgICAgICAgICAgc2VsZi5fcmVzZXRFcnJvcnMoZmFsc2UpO1xyXG4gICAgICAgICAgICBzZWxmLmFqYXhBYm9ydGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgIHNlbGYuYWpheFJlcXVlc3RzID0gW107XHJcbiAgICAgICAgICAgIHNlbGYuX3Jlc2V0Q2FudmFzKCk7XHJcbiAgICAgICAgICAgIHNlbGYuY2FjaGVJbml0aWFsUHJldmlldyA9IHt9O1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5vdmVyd3JpdGVJbml0aWFsKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3ID0gW107XHJcbiAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3Q29uZmlnID0gW107XHJcbiAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3VGh1bWJUYWdzID0gW107XHJcbiAgICAgICAgICAgICAgICBzZWxmLnByZXZpZXdDYWNoZS5kYXRhID0ge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFtdLFxyXG4gICAgICAgICAgICAgICAgICAgIGNvbmZpZzogW10sXHJcbiAgICAgICAgICAgICAgICAgICAgdGFnczogW11cclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9yZXNldENhbnZhczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLmNhbnZhcyAmJiBzZWxmLmltYWdlQ2FudmFzQ29udGV4dCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5pbWFnZUNhbnZhc0NvbnRleHQuY2xlYXJSZWN0KDAsIDAsIHNlbGYuY2FudmFzLndpZHRoLCBzZWxmLmNhbnZhcy5oZWlnaHQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaGFzSW5pdGlhbFByZXZpZXc6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gIXNlbGYub3ZlcndyaXRlSW5pdGlhbCAmJiBzZWxmLnByZXZpZXdDYWNoZS5jb3VudCgpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3Jlc2V0UHJldmlldzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIG91dCwgY2FwO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5wcmV2aWV3Q2FjaGUuY291bnQoKSkge1xyXG4gICAgICAgICAgICAgICAgb3V0ID0gc2VsZi5wcmV2aWV3Q2FjaGUub3V0KCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcmV2aWV3Q29udGVudChvdXQuY29udGVudCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zZXRJbml0VGh1bWJBdHRyKCk7XHJcbiAgICAgICAgICAgICAgICBjYXAgPSBzZWxmLmluaXRpYWxDYXB0aW9uID8gc2VsZi5pbml0aWFsQ2FwdGlvbiA6IG91dC5jYXB0aW9uO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fc2V0Q2FwdGlvbihjYXApO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fY2xlYXJQcmV2aWV3KCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9pbml0Q2FwdGlvbigpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9pbml0Wm9vbSgpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFNvcnRhYmxlKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9jbGVhckRlZmF1bHRQcmV2aWV3OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgc2VsZi4kcHJldmlldy5maW5kKCcuZmlsZS1kZWZhdWx0LXByZXZpZXcnKS5yZW1vdmUoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF92YWxpZGF0ZURlZmF1bHRQcmV2aWV3OiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3IHx8ICRoLmlzRW1wdHkoc2VsZi5kZWZhdWx0UHJldmlld0NvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fc2V0UHJldmlld0NvbnRlbnQoJzxkaXYgY2xhc3M9XCJmaWxlLWRlZmF1bHQtcHJldmlld1wiPicgKyBzZWxmLmRlZmF1bHRQcmV2aWV3Q29udGVudCArICc8L2Rpdj4nKTtcclxuICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyLnJlbW92ZUNsYXNzKCdmaWxlLWlucHV0LW5ldycpO1xyXG4gICAgICAgICAgICBzZWxmLl9pbml0Q2xpY2thYmxlKCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVzZXRQcmV2aWV3VGh1bWJzOiBmdW5jdGlvbiAoaXNBamF4KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgb3V0O1xyXG4gICAgICAgICAgICBpZiAoaXNBamF4KSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jbGVhclByZXZpZXcoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuY2xlYXJTdGFjaygpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzZWxmLl9oYXNJbml0aWFsUHJldmlldygpKSB7XHJcbiAgICAgICAgICAgICAgICBvdXQgPSBzZWxmLnByZXZpZXdDYWNoZS5vdXQoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldFByZXZpZXdDb250ZW50KG91dC5jb250ZW50KTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldEluaXRUaHVtYkF0dHIoKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldENhcHRpb24ob3V0LmNhcHRpb24pO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFByZXZpZXdBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jbGVhclByZXZpZXcoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2dldExheW91dFRlbXBsYXRlOiBmdW5jdGlvbiAodCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHRlbXBsYXRlID0gc2VsZi5sYXlvdXRUZW1wbGF0ZXNbdF07XHJcbiAgICAgICAgICAgIGlmICgkaC5pc0VtcHR5KHNlbGYuY3VzdG9tTGF5b3V0VGFncykpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiB0ZW1wbGF0ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gJGgucmVwbGFjZVRhZ3ModGVtcGxhdGUsIHNlbGYuY3VzdG9tTGF5b3V0VGFncyk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0UHJldmlld1RlbXBsYXRlOiBmdW5jdGlvbiAodCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHRlbXBsYXRlID0gc2VsZi5wcmV2aWV3VGVtcGxhdGVzW3RdO1xyXG4gICAgICAgICAgICBpZiAoJGguaXNFbXB0eShzZWxmLmN1c3RvbVByZXZpZXdUYWdzKSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRlbXBsYXRlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiAkaC5yZXBsYWNlVGFncyh0ZW1wbGF0ZSwgc2VsZi5jdXN0b21QcmV2aWV3VGFncyk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0T3V0RGF0YTogZnVuY3Rpb24gKGpxWEhSLCByZXNwb25zZURhdGEsIGZpbGVzRGF0YSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIGpxWEhSID0ganFYSFIgfHwge307XHJcbiAgICAgICAgICAgIHJlc3BvbnNlRGF0YSA9IHJlc3BvbnNlRGF0YSB8fCB7fTtcclxuICAgICAgICAgICAgZmlsZXNEYXRhID0gZmlsZXNEYXRhIHx8IHNlbGYuZmlsZXN0YWNrLnNsaWNlKDApIHx8IHt9O1xyXG4gICAgICAgICAgICByZXR1cm4ge1xyXG4gICAgICAgICAgICAgICAgZm9ybTogc2VsZi5mb3JtZGF0YSxcclxuICAgICAgICAgICAgICAgIGZpbGVzOiBmaWxlc0RhdGEsXHJcbiAgICAgICAgICAgICAgICBmaWxlbmFtZXM6IHNlbGYuZmlsZW5hbWVzLFxyXG4gICAgICAgICAgICAgICAgZmlsZXNjb3VudDogc2VsZi5nZXRGaWxlc0NvdW50KCksXHJcbiAgICAgICAgICAgICAgICBleHRyYTogc2VsZi5fZ2V0RXh0cmFEYXRhKCksXHJcbiAgICAgICAgICAgICAgICByZXNwb25zZTogcmVzcG9uc2VEYXRhLFxyXG4gICAgICAgICAgICAgICAgcmVhZGVyOiBzZWxm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V3SWQsIGluZGV4KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgZGF0YSA9IHNlbGYudXBsb2FkRXh0cmFEYXRhO1xyXG4gICAgICAgICAgICBpZiAodHlwZW9mIHNlbGYudXBsb2FkRXh0cmFEYXRhID09PSAnZnVuY3Rpb24nKSB7XHJcbiAgICAgICAgICAgICAgICBkYXRhID0gc2VsZi51cGxvYWRFeHRyYURhdGEocHJldmlld0lkLCBpbmRleCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGRhdGE7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdFhocjogZnVuY3Rpb24gKHhocm9iaiwgcHJldmlld0lkLCBmaWxlQ291bnQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoeGhyb2JqLnVwbG9hZCkge1xyXG4gICAgICAgICAgICAgICAgeGhyb2JqLnVwbG9hZC5hZGRFdmVudExpc3RlbmVyKCdwcm9ncmVzcycsIGZ1bmN0aW9uIChldmVudCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBwY3QgPSAwLCB0b3RhbCA9IGV2ZW50LnRvdGFsLCBwb3NpdGlvbiA9IGV2ZW50LmxvYWRlZCB8fCBldmVudC5wb3NpdGlvbjtcclxuICAgICAgICAgICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBldmVudC5sZW5ndGhDb21wdXRhYmxlICovXHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lmxlbmd0aENvbXB1dGFibGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGN0ID0gTWF0aC5mbG9vcihwb3NpdGlvbiAvIHRvdGFsICogMTAwKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByZXZpZXdJZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRBc3luY1VwbG9hZFN0YXR1cyhwcmV2aWV3SWQsIHBjdCwgZmlsZUNvdW50KTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcm9ncmVzcyhwY3QpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0sIGZhbHNlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4geGhyb2JqO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRBamF4U2V0dGluZ3M6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBzZWxmLl9hamF4U2V0dGluZ3MgPSAkLmV4dGVuZCh0cnVlLCB7fSwgc2VsZi5hamF4U2V0dGluZ3MpO1xyXG4gICAgICAgICAgICBzZWxmLl9hamF4RGVsZXRlU2V0dGluZ3MgPSAkLmV4dGVuZCh0cnVlLCB7fSwgc2VsZi5hamF4RGVsZXRlU2V0dGluZ3MpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX21lcmdlQWpheENhbGxiYWNrOiBmdW5jdGlvbiAoZnVuY05hbWUsIHNyY0Z1bmMsIHR5cGUpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBzZXR0aW5ncyA9IHNlbGYuX2FqYXhTZXR0aW5ncywgZmxhZyA9IHNlbGYubWVyZ2VBamF4Q2FsbGJhY2tzLCB0YXJnRnVuYztcclxuICAgICAgICAgICAgaWYgKHR5cGUgPT09ICdkZWxldGUnKSB7XHJcbiAgICAgICAgICAgICAgICBzZXR0aW5ncyA9IHNlbGYuX2FqYXhEZWxldGVTZXR0aW5ncztcclxuICAgICAgICAgICAgICAgIGZsYWcgPSBzZWxmLm1lcmdlQWpheERlbGV0ZUNhbGxiYWNrcztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB0YXJnRnVuYyA9IHNldHRpbmdzW2Z1bmNOYW1lXTtcclxuICAgICAgICAgICAgaWYgKGZsYWcgJiYgdHlwZW9mIHRhcmdGdW5jID09PSAnZnVuY3Rpb24nKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoZmxhZyA9PT0gJ2JlZm9yZScpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZXR0aW5nc1tmdW5jTmFtZV0gPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdGdW5jLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyY0Z1bmMuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBzZXR0aW5nc1tmdW5jTmFtZV0gPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyY0Z1bmMuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ0Z1bmMuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgc2V0dGluZ3NbZnVuY05hbWVdID0gc3JjRnVuYztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2FqYXhTdWJtaXQ6IGZ1bmN0aW9uIChmbkJlZm9yZSwgZm5TdWNjZXNzLCBmbkNvbXBsZXRlLCBmbkVycm9yLCBwcmV2aWV3SWQsIGluZGV4KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgc2V0dGluZ3MsIHZVcmw7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5fcmFpc2UoJ2ZpbGVwcmVhamF4JywgW3ByZXZpZXdJZCwgaW5kZXhdKSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX3VwbG9hZEV4dHJhKHByZXZpZXdJZCwgaW5kZXgpO1xyXG4gICAgICAgICAgICBzZWxmLl9pbml0QWpheFNldHRpbmdzKCk7XHJcbiAgICAgICAgICAgIHNlbGYuX21lcmdlQWpheENhbGxiYWNrKCdiZWZvcmVTZW5kJywgZm5CZWZvcmUpO1xyXG4gICAgICAgICAgICBzZWxmLl9tZXJnZUFqYXhDYWxsYmFjaygnc3VjY2VzcycsIGZuU3VjY2Vzcyk7XHJcbiAgICAgICAgICAgIHNlbGYuX21lcmdlQWpheENhbGxiYWNrKCdjb21wbGV0ZScsIGZuQ29tcGxldGUpO1xyXG4gICAgICAgICAgICBzZWxmLl9tZXJnZUFqYXhDYWxsYmFjaygnZXJyb3InLCBmbkVycm9yKTtcclxuICAgICAgICAgICAgdlVybCA9IGluZGV4ICYmIHNlbGYudXBsb2FkVXJsVGh1bWIgPyBzZWxmLnVwbG9hZFVybFRodW1iIDogc2VsZi51cGxvYWRVcmw7XHJcbiAgICAgICAgICAgIHNldHRpbmdzID0gJC5leHRlbmQodHJ1ZSwge30sIHtcclxuICAgICAgICAgICAgICAgIHhocjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciB4aHJvYmogPSAkLmFqYXhTZXR0aW5ncy54aHIoKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VsZi5faW5pdFhocih4aHJvYmosIHByZXZpZXdJZCwgc2VsZi5nZXRGaWxlU3RhY2soKS5sZW5ndGgpO1xyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgICAgIHVybDogc2VsZi5fZW5jb2RlVVJJKHZVcmwpLFxyXG4gICAgICAgICAgICAgICAgdHlwZTogJ1BPU1QnLFxyXG4gICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcclxuICAgICAgICAgICAgICAgIGRhdGE6IHNlbGYuZm9ybWRhdGEsXHJcbiAgICAgICAgICAgICAgICBjYWNoZTogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICBwcm9jZXNzRGF0YTogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICBjb250ZW50VHlwZTogZmFsc2VcclxuICAgICAgICAgICAgfSwgc2VsZi5fYWpheFNldHRpbmdzKTtcclxuICAgICAgICAgICAgc2VsZi5hamF4UmVxdWVzdHMucHVzaCgkLmFqYXgoc2V0dGluZ3MpKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9tZXJnZUFycmF5OiBmdW5jdGlvbiAocHJvcCwgY29udGVudCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGFycjEgPSAkaC5jbGVhbkFycmF5KHNlbGZbcHJvcF0pLCBhcnIyID0gJGguY2xlYW5BcnJheShjb250ZW50KTtcclxuICAgICAgICAgICAgc2VsZltwcm9wXSA9IGFycjEuY29uY2F0KGFycjIpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRVcGxvYWRTdWNjZXNzOiBmdW5jdGlvbiAob3V0LCAkdGh1bWIsIGFsbEZpbGVzKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgYXBwZW5kLCBkYXRhLCBpbmRleCwgJGRpdiwgJG5ld0NhY2hlLCBjb250ZW50LCBjb25maWcsIHRhZ3MsIGk7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5zaG93UHJldmlldyB8fCB0eXBlb2Ygb3V0ICE9PSAnb2JqZWN0JyB8fCAkLmlzRW1wdHlPYmplY3Qob3V0KSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChvdXQuaW5pdGlhbFByZXZpZXcgIT09IHVuZGVmaW5lZCAmJiBvdXQuaW5pdGlhbFByZXZpZXcubGVuZ3RoID4gMCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5oYXNJbml0RGF0YSA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICBjb250ZW50ID0gb3V0LmluaXRpYWxQcmV2aWV3IHx8IFtdO1xyXG4gICAgICAgICAgICAgICAgY29uZmlnID0gb3V0LmluaXRpYWxQcmV2aWV3Q29uZmlnIHx8IFtdO1xyXG4gICAgICAgICAgICAgICAgdGFncyA9IG91dC5pbml0aWFsUHJldmlld1RodW1iVGFncyB8fCBbXTtcclxuICAgICAgICAgICAgICAgIGFwcGVuZCA9IG91dC5hcHBlbmQgPT09IHVuZGVmaW5lZCB8fCBvdXQuYXBwZW5kO1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMCAmJiAhJGguaXNBcnJheShjb250ZW50KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBjb250ZW50LnNwbGl0KHNlbGYuaW5pdGlhbFByZXZpZXdEZWxpbWl0ZXIpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgc2VsZi5fbWVyZ2VBcnJheSgnaW5pdGlhbFByZXZpZXcnLCBjb250ZW50KTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX21lcmdlQXJyYXkoJ2luaXRpYWxQcmV2aWV3Q29uZmlnJywgY29uZmlnKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX21lcmdlQXJyYXkoJ2luaXRpYWxQcmV2aWV3VGh1bWJUYWdzJywgdGFncyk7XHJcbiAgICAgICAgICAgICAgICBpZiAoJHRodW1iICE9PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWFsbEZpbGVzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0gc2VsZi5wcmV2aWV3Q2FjaGUuYWRkKGNvbnRlbnQsIGNvbmZpZ1swXSwgdGFnc1swXSwgYXBwZW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNlbGYucHJldmlld0NhY2hlLmdldChpbmRleCwgZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkZGl2ID0gJChkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKSkuaHRtbChkYXRhKS5oaWRlKCkuaW5zZXJ0QWZ0ZXIoJHRodW1iKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJG5ld0NhY2hlID0gJGRpdi5maW5kKCcua3Ytem9vbS1jYWNoZScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoJG5ld0NhY2hlICYmICRuZXdDYWNoZS5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRuZXdDYWNoZS5pbnNlcnRBZnRlcigkdGh1bWIpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYi5mYWRlT3V0KCdzbG93JywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyICRuZXdUaHVtYiA9ICRkaXYuZmluZCgnLmZpbGUtcHJldmlldy1mcmFtZScpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRuZXdUaHVtYiAmJiAkbmV3VGh1bWIubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJG5ld1RodW1iLmluc2VydEJlZm9yZSgkdGh1bWIpLmZhZGVJbignc2xvdycpLmNzcygnZGlzcGxheTppbmxpbmUtYmxvY2snKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2luaXRQcmV2aWV3QWN0aW9ucygpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fY2xlYXJGaWxlSW5wdXQoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRoLmNsZWFuWm9vbUNhY2hlKHNlbGYuJHByZXZpZXcuZmluZCgnI3pvb20tJyArICR0aHVtYi5hdHRyKCdpZCcpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWIucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkZGl2LnJlbW92ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdFNvcnRhYmxlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGkgPSAkdGh1bWIuYXR0cignZGF0YS1maWxlaW5kZXgnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRDYWNoZS5jb250ZW50W2ldID0gY29udGVudFswXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRDYWNoZS5jb25maWdbaV0gPSBjb25maWdbMF0gfHwgW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkQ2FjaGUudGFnc1tpXSA9IHRhZ3NbMF0gfHwgW107XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkQ2FjaGUuYXBwZW5kID0gYXBwZW5kO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5wcmV2aWV3Q2FjaGUuc2V0KGNvbnRlbnQsIGNvbmZpZywgdGFncywgYXBwZW5kKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0UHJldmlldygpO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2luaXRQcmV2aWV3QWN0aW9ucygpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaW5pdFN1Y2Nlc3NUaHVtYnM6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuc2hvd1ByZXZpZXcpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl9nZXRUaHVtYnMoJGguRlJBTUVTICsgJy5maWxlLXByZXZpZXctc3VjY2VzcycpLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyksICRwcmV2aWV3ID0gc2VsZi4kcHJldmlldywgJHJlbW92ZSA9ICR0aHVtYi5maW5kKCcua3YtZmlsZS1yZW1vdmUnKTtcclxuICAgICAgICAgICAgICAgICRyZW1vdmUucmVtb3ZlQXR0cignZGlzYWJsZWQnKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2hhbmRsZXIoJHJlbW92ZSwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBpZCA9ICR0aHVtYi5hdHRyKCdpZCcpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICBvdXQgPSBzZWxmLl9yYWlzZSgnZmlsZXN1Y2Nlc3NyZW1vdmUnLCBbaWQsICR0aHVtYi5hdHRyKCdkYXRhLWZpbGVpbmRleCcpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGguY2xlYW5NZW1vcnkoJHRodW1iKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAob3V0ID09PSBmYWxzZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5mYWRlT3V0KCdzbG93JywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkaC5jbGVhblpvb21DYWNoZSgkcHJldmlldy5maW5kKCcjem9vbS0nICsgaWQpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJHRodW1iLnJlbW92ZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXNlbGYuZ2V0RnJhbWVzKCkubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnJlc2V0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9jaGVja0FzeW5jQ29tcGxldGU6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBwcmV2aWV3SWQsIGk7XHJcbiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBzZWxmLmZpbGVzdGFjay5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgaWYgKHNlbGYuZmlsZXN0YWNrW2ldKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJldmlld0lkID0gc2VsZi5wcmV2aWV3SW5pdElkICsgJy0nICsgaTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoJC5pbkFycmF5KHByZXZpZXdJZCwgc2VsZi51cGxvYWRMb2cpID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiAoc2VsZi51cGxvYWRBc3luY0NvdW50ID09PSBzZWxmLnVwbG9hZExvZy5sZW5ndGgpO1xyXG4gICAgICAgIH0sXHJcbiAgICA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ZSwgZm5FcnJvcixcclxuICAgICAgICAgICAgICAgIHVwZGF0ZVVwbG9hZExvZywgcGFyYW1zID0ge2lkOiBwcmV2aWV3SWQsIGluZGV4OiBpfTtcclxuICAgICAgICAgICAgc2VsZi5mb3JtZGF0YSA9IGZvcm1kYXRhO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5zaG93UHJldmlldykge1xyXG4gICAgICAgICAgICAgICAgJHRodW1iID0gJCgnIycgKyBwcmV2aWV3SWQgKyAnOm5vdCguZmlsZS1wcmV2aWV3LWluaXRpYWwpJyk7XHJcbiAgICAgICAgICAgICAgICAkYnRuVXBsb2FkID0gJHRodW1iLmZpbmQoJy5rdi1maWxlLXVwbG9hZCcpO1xyXG4gICAgICAgICAgICAgICAgJGJ0bkRlbGV0ZSA9ICR0aHVtYi5maW5kKCcua3YtZmlsZS1yZW1vdmUnKTtcclxuICAgICAgICAgICAgICAgICRwcm9nLnNob3coKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAodG90YWwgPT09IDAgfHwgIWhhc1Bvc3REYXRhIHx8ICgkYnRuVXBsb2FkICYmICRidG5VcGxvYWQuaGFzQ2xhc3MoJ2Rpc2FibGVkJykpIHx8IHNlbGYuX2Fib3J0KHBhcmFtcykpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB1cGRhdGVVcGxvYWRMb2cgPSBmdW5jdGlvbiAoaSwgcHJldmlld0lkKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIXVwbG9hZEZhaWxlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYudXBkYXRlU3RhY2soaSwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkTG9nLnB1c2gocHJldmlld0lkKTtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLl9jaGVja0FzeW5jQ29tcGxldGUoKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuZmlsZUJhdGNoQ29tcGxldGVkID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgY2hrQ29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgdSA9IHNlbGYudXBsb2FkQ2FjaGUsICRpbml0VGh1bWJzLCBpLCBqLCBsZW4gPSAwLCBkYXRhID0gc2VsZi5jYWNoZUluaXRpYWxQcmV2aWV3O1xyXG4gICAgICAgICAgICAgICAgaWYgKCFzZWxmLmZpbGVCYXRjaENvbXBsZXRlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChkYXRhICYmIGRhdGEuY29udGVudCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGxlbiA9IGRhdGEuY29udGVudC5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgdHJpZ2dlclJlc2V0ID0gc2VsZi5nZXRGaWxlU3RhY2sodHJ1ZSkubGVuZ3RoID09PSAwO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlLnNldCh1LmNvbnRlbnQsIHUuY29uZmlnLCB1LnRhZ3MsIHUuYXBwZW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxlbikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHUuY29udGVudC5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGogPSBpICsgbGVuO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuY29udGVudFtqXSA9IHUuY29udGVudFtpXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL25vaW5zcGVjdGlvbiBKU1VucmVzb2x2ZWRWYXJpYWJsZVxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNvbmZpZy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5jb25maWdbal0gPSB1LmNvbmZpZ1tpXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEudGFncy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS50YWdzW2pdID0gdS50YWdzW2ldO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuaW5pdGlhbFByZXZpZXcgPSAkaC5jbGVhbkFycmF5KGRhdGEuY29udGVudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3Q29uZmlnID0gJGguY2xlYW5BcnJheShkYXRhLmNvbmZpZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmluaXRpYWxQcmV2aWV3VGh1bWJUYWdzID0gJGguY2xlYW5BcnJheShkYXRhLnRhZ3MpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5pbml0aWFsUHJldmlldyA9IHUuY29udGVudDtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuaW5pdGlhbFByZXZpZXdDb25maWcgPSB1LmNvbmZpZztcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuaW5pdGlhbFByZXZpZXdUaHVtYlRhZ3MgPSB1LnRhZ3M7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jYWNoZUluaXRpYWxQcmV2aWV3ID0ge307XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLmhhc0luaXREYXRhKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0UHJldmlldygpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdFByZXZpZXdBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi51bmxvY2sodHJpZ2dlclJlc2V0KTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAodHJpZ2dlclJlc2V0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyRmlsZUlucHV0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICRpbml0VGh1bWJzID0gc2VsZi4kcHJldmlldy5maW5kKCcuZmlsZS1wcmV2aWV3LWluaXRpYWwnKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi51cGxvYWRBc3luYyAmJiAkaW5pdFRodW1icy5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGguYWRkQ3NzKCRpbml0VGh1bWJzLCAkaC5TT1JUX0NTUyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2luaXRTb3J0YWJsZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWJhdGNodXBsb2FkY29tcGxldGUnLCBbc2VsZi5maWxlc3RhY2ssIHNlbGYuX2dldEV4dHJhRGF0YSgpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRDb3VudCA9IDA7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRTdGF0dXMgPSB7fTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnVwbG9hZExvZyA9IFtdO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzKDEwMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5hamF4QWJvcnRlZCA9IGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfSwgMTAwKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgZm5CZWZvcmUgPSBmdW5jdGlvbiAoanFYSFIpIHtcclxuICAgICAgICAgICAgICAgIG91dERhdGEgPSBzZWxmLl9nZXRPdXREYXRhKGpxWEhSKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuZmlsZUJhdGNoQ29tcGxldGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICBpZiAoIWlzQmF0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmFqYXhBYm9ydGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoc2VsZi5zaG93UHJldmlldykge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghJHRodW1iLmhhc0NsYXNzKCdmaWxlLXByZXZpZXctc3VjY2VzcycpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFRodW1iU3RhdHVzKCR0aHVtYiwgJ0xvYWRpbmcnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGguYWRkQ3NzKCR0aHVtYiwgJ2ZpbGUtdXBsb2FkaW5nJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICRidG5VcGxvYWQuYXR0cignZGlzYWJsZWQnLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAkYnRuRGVsZXRlLmF0dHIoJ2Rpc2FibGVkJywgdHJ1ZSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoIWlzQmF0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmxvY2soKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlcHJldXBsb2FkJywgW291dERhdGEsIHByZXZpZXdJZCwgaV0pO1xyXG4gICAgICAgICAgICAgICAgJC5leHRlbmQodHJ1ZSwgcGFyYW1zLCBvdXREYXRhKTtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLl9hYm9ydChwYXJhbXMpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAganFYSFIuYWJvcnQoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQmF0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0VGh1bWJTdGF0dXMoJHRodW1iLCAnTmV3Jyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYi5yZW1vdmVDbGFzcygnZmlsZS11cGxvYWRpbmcnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGJ0blVwbG9hZC5yZW1vdmVBdHRyKCdkaXNhYmxlZCcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkYnRuRGVsZXRlLnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudW5sb2NrKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzQ2FuY2VsbGVkKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGZuU3VjY2VzcyA9IGZ1bmN0aW9uIChkYXRhLCB0ZXh0U3RhdHVzLCBqcVhIUikge1xyXG4gICAgICAgICAgICAgICAgdmFyIHBpZCA9IHNlbGYuc2hvd1ByZXZpZXcgJiYgJHRodW1iLmF0dHIoJ2lkJykgPyAkdGh1bWIuYXR0cignaWQnKSA6IHByZXZpZXdJZDtcclxuICAgICAgICAgICAgICAgIG91dERhdGEgPSBzZWxmLl9nZXRPdXREYXRhKGpxWEhSLCBkYXRhKTtcclxuICAgICAgICAgICAgICAgICQuZXh0ZW5kKHRydWUsIHBhcmFtcywgb3V0RGF0YSk7XHJcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eShkYXRhKSB8fCAkaC5pc0VtcHR5KGRhdGEuZXJyb3IpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRUaHVtYlN0YXR1cygkdGh1bWIsICdTdWNjZXNzJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkYnRuVXBsb2FkLmhpZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2luaXRVcGxvYWRTdWNjZXNzKGRhdGEsICR0aHVtYiwgaXNCYXRjaCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcm9ncmVzcygxMDEsICRwcm9nKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZXVwbG9hZGVkJywgW291dERhdGEsIHBpZCwgaV0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQmF0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudXBkYXRlU3RhY2soaSwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZVVwbG9hZExvZyhpLCBwaWQpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXBsb2FkRmFpbGVkID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2hvd1VwbG9hZEVycm9yKGRhdGEuZXJyb3IsIHBhcmFtcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByZXZpZXdFcnJvcigkdGh1bWIsIGksIHNlbGYuZmlsZXN0YWNrW2ldLCBzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkYnRuVXBsb2FkLmhpZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNCYXRjaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlVXBsb2FkTG9nKGksIHBpZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMTAxLCAkKCcjJyArIHBpZCkuZmluZCgnLmZpbGUtdGh1bWItcHJvZ3Jlc3MnKSwgc2VsZi5tc2dVcGxvYWRFcnJvcik7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfSwgMTAwKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgZm5Db21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRidG5VcGxvYWQucmVtb3ZlQXR0cignZGlzYWJsZWQnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkRlbGV0ZS5yZW1vdmVBdHRyKCdkaXNhYmxlZCcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWIucmVtb3ZlQ2xhc3MoJ2ZpbGUtdXBsb2FkaW5nJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmICghaXNCYXRjaCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnVubG9jayhmYWxzZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyRmlsZUlucHV0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY2hrQ29tcGxldGUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdFN1Y2Nlc3NUaHVtYnMoKTtcclxuICAgICAgICAgICAgICAgIH0sIDEwMCk7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGZuRXJyb3IgPSBmdW5jdGlvbiAoanFYSFIsIHRleHRTdGF0dXMsIGVycm9yVGhyb3duKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgb3AgPSBzZWxmLmFqYXhPcGVyYXRpb25zLnVwbG9hZFRodW1iLFxyXG4gICAgICAgICAgICAgICAgICAgIGVyck1zZyA9IHNlbGYuX3BhcnNlRXJyb3Iob3AsIGpxWEhSLCBlcnJvclRocm93bixcclxuICAgICAgICAgICAgICAgICAgICAgICAgKGlzQmF0Y2ggJiYgc2VsZi5maWxlc3RhY2tbaV0ubmFtZSA/IHNlbGYuZmlsZXN0YWNrW2ldLm5hbWUgOiBudWxsKSk7XHJcbiAgICAgICAgICAgICAgICB1cGxvYWRGYWlsZWQgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQmF0Y2gpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlVXBsb2FkTG9nKGksIHByZXZpZXdJZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkU3RhdHVzW3ByZXZpZXdJZF0gPSAxMDA7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0UHJldmlld0Vycm9yKCR0aHVtYiwgaSwgc2VsZi5maWxlc3RhY2tbaV0sIHNlbGYucmV0cnlFcnJvclVwbG9hZHMpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghc2VsZi5yZXRyeUVycm9yVXBsb2Fkcykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkYnRuVXBsb2FkLmhpZGUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgJC5leHRlbmQodHJ1ZSwgcGFyYW1zLCBzZWxmLl9nZXRPdXREYXRhKGpxWEhSKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMTAxLCAkcHJvZywgc2VsZi5tc2dBamF4UHJvZ3Jlc3NFcnJvci5yZXBsYWNlKCd7b3BlcmF0aW9ufScsIG9wKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMTAxLCAkKCcjJyArIHByZXZpZXdJZCkuZmluZCgnLmZ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biAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2V0QWxsVXBsb2FkZWQgPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAkLmVhY2goZmlsZXMsIGZ1bmN0aW9uIChrZXkpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnVwZGF0ZVN0YWNrKGtleSwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fY2xlYXJGaWxlSW5wdXQoKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgZm5CZWZvcmUgPSBmdW5jdGlvbiAoanFYSFIpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYubG9jaygpO1xyXG4gICAgICAgICAgICAgICAgdmFyIG91dERhdGEgPSBzZWxmLl9nZXRPdXREYXRhKGpxWEhSKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuYWpheEFib3J0ZWQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fZ2V0VGh1bWJzKCkuZWFjaChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkdGh1bWIgPSAkKHRoaXMpLCAkYnRuVXBsb2FkID0gJHRodW1iLmZpbmQoJy5rdi1maWxlLXVwbG9hZCcpLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkRlbGV0ZSA9ICR0aHVtYi5maW5kKCcua3YtZmlsZS1yZW1vdmUnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEkdGh1bWIuaGFzQ2xhc3MoJ2ZpbGUtcHJldmlldy1zdWNjZXNzJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFRodW1iU3RhdHVzKCR0aHVtYiwgJ0xvYWRpbmcnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRoLmFkZENzcygkdGh1bWIsICdmaWxlLXVwbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRidG5VcGxvYWQuYXR0cignZGlzYWJsZWQnLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkRlbGV0ZS5hdHRyKCdkaXNhYmxlZCcsIHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGViYXRjaHByZXVwbG9hZCcsIFtvdXREYXRhXSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2VsZi5fYWJvcnQob3V0RGF0YSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBqcVhIUi5hYm9ydCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2dldFRodW1icygpLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgJHRodW1iID0gJCh0aGlzKSwgJGJ0blVwbG9hZCA9ICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKSxcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRidG5EZWxldGUgPSAkdGh1bWIuZmluZCgnLmt2LWZpbGUtcmVtb3ZlJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkdGh1bWIuaGFzQ2xhc3MoJ2ZpbGUtcHJldmlldy1sb2FkaW5nJykpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFRodW1iU3RhdHVzKCR0aHVtYiwgJ05ldycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJHRodW1iLnJlbW92ZUNsYXNzKCdmaWxlLXVwbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRidG5VcGxvYWQucmVtb3ZlQXR0cignZGlzYWJsZWQnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGJ0bkRlbGV0ZS5yZW1vdmVBdHRyKCdkaXNhYmxlZCcpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzQ2FuY2VsbGVkKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGZuU3VjY2VzcyA9IGZ1bmN0aW9uIChkYXRhLCB0ZXh0U3RhdHVzLCBqcVhIUikge1xyXG4gICAgICAgICAgICAgICAgLyoqIEBuYW1lc3BhY2UgZGF0YS5lcnJvcmtleXMgKi9cclxuICAgICAgICAgICAgICAgIHZhciBvdXREYXRhID0gc2VsZi5fZ2V0T3V0RGF0YShqcVhIUiwgZGF0YSksIGtleSA9IDAsXHJcbiAgICAgICAgICAgICAgICAgICAgJHRodW1icyA9IHNlbGYuX2dldFRodW1icygnOm5vdCguZmlsZS1wcmV2aWV3LXN1Y2Nlc3MpJyksXHJcbiAgICAgICAgICAgICAgICAgICAga2V5cyA9ICRoLmlzRW1wdHkoZGF0YSkgfHwgJGguaXNFbXB0eShkYXRhLmVycm9ya2V5cykgPyBbXSA6IGRhdGEuZXJyb3JrZXlzO1xyXG5cclxuICAgICAgICAgICAgICAgIGlmICgkaC5pc0VtcHR5KGRhdGEpIHx8ICRoLmlzRW1wdHkoZGF0YS5lcnJvcikpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWJhdGNodXBsb2Fkc3VjY2VzcycsIFtvdXREYXRhXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2V0QWxsVXBsb2FkZWQoKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5zaG93UHJldmlldykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWJzLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRUaHVtYlN0YXR1cygkdGh1bWIsICdTdWNjZXNzJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWIucmVtb3ZlQ2xhc3MoJ2ZpbGUtdXBsb2FkaW5nJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWIuZmluZCgnLmt2LWZpbGUtdXBsb2FkJykuaGlkZSgpLnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0VXBsb2FkU3VjY2VzcyhkYXRhKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnJlc2V0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzKDEwMSk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYnMuZWFjaChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgJHRodW1iID0gJCh0aGlzKSwgaSA9ICR0aHVtYi5hdHRyKCdkYXRhLWZpbGVpbmRleCcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJHRodW1iLnJlbW92ZUNsYXNzKCdmaWxlLXVwbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJHRodW1iLmZpbmQoJy5rdi1maWxlLXVwbG9hZCcpLnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGh1bWIuZmluZCgnLmt2LWZpbGUtcmVtb3ZlJykucmVtb3ZlQXR0cignZGlzYWJsZWQnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZXlzLmxlbmd0aCA9PT0gMCB8fCAkLmluQXJyYXkoa2V5LCBrZXlzKSAhPT0gLTEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcmV2aWV3RXJyb3IoJHRodW1iLCBpLCBzZWxmLmZpbGVzdGFja1tpXSwgc2VsZi5yZXRyeUVycm9yVXBsb2Fkcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKS5oaWRlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudXBkYXRlU3RhY2soaSwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKS5oaWRlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0VGh1bWJTdGF0dXMoJHRodW1iLCAnU3VjY2VzcycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYudXBkYXRlU3RhY2soaSwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghJHRodW1iLmhhc0NsYXNzKCdmaWxlLXByZXZpZXctZXJyb3InKSB8fCBzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5Kys7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0VXBsb2FkU3VjY2VzcyhkYXRhKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2hvd1VwbG9hZEVycm9yKGRhdGEuZXJyb3IsIG91dERhdGEsICdmaWxlYmF0Y2h1cGxvYWRlcnJvcicpO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzKDEwMSwgc2VsZi4kcHJvZ3Jlc3MsIHNlbGYubXNnVXBsb2FkRXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICBmbkNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi51bmxvY2soKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2luaXRTdWNjZXNzVGh1bWJzKCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jbGVhckZpbGVJbnB1dCgpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGViYXRjaHVwbG9hZGNvbXBsZXRlJywgW3NlbGYuZmlsZXN0YWNrLCBzZWxmLl9nZXRFeHRyYURhdGEoKV0pO1xyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICBmbkVycm9yID0gZnVuY3Rpb24gKGpxWEhSLCB0ZXh0U3RhdHVzLCBlcnJvclRocm93bikge1xyXG4gICAgICAgICAgICAgICAgdmFyIG91dERhdGEgPSBzZWxmLl9nZXRPdXREYXRhKGpxWEhSKSwgb3AgPSBzZWxmLmFqYXhPcGVyYXRpb25zLnVwbG9hZEJhdGNoLFxyXG4gICAgICAgICAgICAgICAgICAgIGVyck1zZyA9IHNlbGYuX3BhcnNlRXJyb3Iob3AsIGpxWEhSLCBlcnJvclRocm93bik7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zaG93VXBsb2FkRXJyb3IoZXJyTXNnLCBvdXREYXRhLCAnZmlsZWJhdGNodXBsb2FkZXJyb3InKTtcclxuICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkRmlsZUNvdW50ID0gdG90YWwgLSAxO1xyXG4gICAgICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgc2VsZi5fZ2V0VGh1bWJzKCkuZWFjaChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyksIGtleSA9ICR0aHVtYi5hdHRyKCdkYXRhLWZpbGVpbmRleCcpO1xyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5yZW1vdmVDbGFzcygnZmlsZS11cGxvYWRpbmcnKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5maWxlc3RhY2tba2V5XSAhPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldFByZXZpZXdFcnJvcigkdGh1bWIpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fZ2V0VGh1bWJzKCkucmVtb3ZlQ2xhc3MoJ2ZpbGUtdXBsb2FkaW5nJy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ICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZuQmVmb3JlID0gZnVuY3Rpb24gKGpxWEhSKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmxvY2soKTtcclxuICAgICAgICAgICAgICAgIHZhciBvdXREYXRhID0gc2VsZi5fZ2V0T3V0RGF0YShqcVhIUik7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWJhdGNocHJldXBsb2FkJywgW291dERhdGFdKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzKDUwKTtcclxuICAgICAgICAgICAgICAgIHBhcmFtcy5kYXRhID0gb3V0RGF0YTtcclxuICAgICAgICAgICAgICAgIHBhcmFtcy54aHIgPSBqcVhIUjtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLl9hYm9ydChwYXJhbXMpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAganFYSFIuYWJvcnQoKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcm9ncmVzc0NhbmNlbGxlZCgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICBmblN1Y2Nlc3MgPSBmdW5jdGlvbiAoZGF0YSwgdGV4dFN0YXR1cywganFYSFIpIHtcclxuICAgICAgICAgICAgICAgIHZhciBvdXREYXRhID0gc2VsZi5fZ2V0T3V0RGF0YShqcVhIUiwgZGF0YSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eShkYXRhKSB8fCAkaC5pc0VtcHR5KGRhdGEuZXJyb3IpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGViYXRjaHVwbG9hZHN1Y2Nlc3MnLCBbb3V0RGF0YV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyRmlsZUlucHV0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdFVwbG9hZFN1Y2Nlc3MoZGF0YSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMTAxKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2hvd1VwbG9hZEVycm9yKGRhdGEuZXJyb3IsIG91dERhdGEsICdmaWxlYmF0Y2h1cGxvYWRlcnJvcicpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICBmbkNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi51bmxvY2soKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyRmlsZUlucHV0KCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWJhdGNodXBsb2FkY29tcGxldGUnLCBbc2VsZi5maWxlc3RhY2ssIHNlbGYuX2dldEV4dHJhRGF0YSgpXSk7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGZuRXJyb3IgPSBmdW5jdGlvbiAoanFYSFIsIHRleHRTdGF0dXMsIGVycm9yVGhyb3duKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgb3V0RGF0YSA9IHNlbGYuX2dldE91dERhdGEoanFYSFIpLCBvcCA9IHNlbGYuYWpheE9wZXJhdGlvbnMudXBsb2FkRXh0cmEsXHJcbiAgICAgICAgICAgICAgICAgICAgZXJyTXNnID0gc2VsZi5fcGFyc2VFcnJvcihvcCwganFYSFIsIGVycm9yVGhyb3duKTtcclxuICAgICAgICAgICAgICAgIHBhcmFtcy5kYXRhID0gb3V0RGF0YTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Nob3dVcGxvYWRFcnJvcihlcnJNc2csIG91dERhdGEsICdmaWxlYmF0Y2h1cGxvYWRlcnJvcicpO1xyXG4gICA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ICAgICAgIHZhciAkbkZyYW1lID0gJCh0aGlzKSwgbkluZCA9ICRuRnJhbWUuYXR0cignZGF0YS1maWxlaW5kZXgnKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAobkluZC5zdWJzdHJpbmcoMCwgNSkgPT09ICdpbml0XycpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbkluZCA9IHBhcnNlSW50KG5JbmQucmVwbGFjZSgnaW5pdF8nLCAnJykpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobkluZCA+IGluZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbkluZC0tO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJG5GcmFtZS5hdHRyKCdkYXRhLWZpbGVpbmRleCcsICdpbml0XycgKyBuSW5kKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgaWYgKHNlbGYudXBsb2FkQXN5bmMpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmNhY2hlSW5pdGlhbFByZXZpZXcgPSBzZWxmLmdldFByZXZpZXcoKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRGaWxlQWN0aW9uczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRwcmV2aWV3ID0gc2VsZi4kcHJldmlldztcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5faW5pdFpvb21CdXR0b24oKTtcclxuICAgICAgICAgICAgc2VsZi5nZXRGcmFtZXMoJyAua3YtZmlsZS1yZW1vdmUnKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHZhciAkZWwgPSAkKHRoaXMpLCAkZnJhbWUgPSAkZWwuY2xvc2VzdCgkaC5GUkFNRVMpLCBoYXNFcnJvciwgaWQgPSAkZnJhbWUuYXR0cignaWQnKSxcclxuICAgICAgICAgICAgICAgICAgICBpbmQgPSAkZnJhbWUuYXR0cignZGF0YS1maWxlaW5kZXgnKSwgbiwgY2FwLCBzdGF0dXM7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCRlbCwgJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IHNlbGYuX3JhaXNlKCdmaWxlcHJlcmVtb3ZlJywgW2lkLCBpbmRdKTtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09PSBmYWxzZSB8fCAhc2VsZi5fdmFsaWRhdGVNaW5Db3VudCgpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgaGFzRXJyb3IgPSAkZnJhbWUuaGFzQ2xhc3MoJ2ZpbGUtcHJldmlldy1lcnJvcicpO1xyXG4gICAgICAgICAgICAgICAgICAgICRoLmNsZWFuTWVtb3J5KCRmcmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGZyYW1lLmZhZGVPdXQoJ3Nsb3cnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRoLmNsZWFuWm9vbUNhY2hlKCRwcmV2aWV3LmZpbmQoJyN6b29tLScgKyBpZCkpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLnVwZGF0ZVN0YWNrKGluZCwgdW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fY2xlYXJPYmplY3RzKCRmcmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRmcmFtZS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkICYmIGhhc0Vycm9yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLiRlcnJvckNvbnRhaW5lci5maW5kKCdsaVtkYXRhLXRodW1iLWlkPVwiJyArIGlkICsgJ1wiXScpLmZhZGVPdXQoJ2Zhc3QnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXNlbGYuX2Vycm9yc0V4aXN0KCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmVzZXRFcnJvcnMoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9jbGVhckZpbGVJbnB1dCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgZmlsZXN0YWNrID0gc2VsZi5nZXRGaWxlU3RhY2sodHJ1ZSksIGNoayA9IHNlbGYucHJldmlld0NhY2hlLmNvdW50KCksXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gPSBmaWxlc3RhY2subGVuZ3RoLCBoYXNUaHVtYiA9IHNlbGYuc2hvd1ByZXZpZXcgJiYgc2VsZi5nZXRGcmFtZXMoKS5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW4gPT09IDAgJiYgY2hrID09PSAwICYmICFoYXNUaHVtYikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5yZXNldCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbiA9IGNoayArIGxlbjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcCA9IG4gPiAxID8gc2VsZi5fZ2V0TXNnU2VsZWN0ZWQobikgOiAoZmlsZXN0YWNrWzBdID8gc2VsZi5fZ2V0RmlsZU5hbWVzKClbMF0gOiAnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRDYXB0aW9uKGNhcCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVyZW1vdmVkJywgW2lkLCBpbmRdKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgc2VsZi5nZXRGcmFtZXMoJyAua3YtZmlsZS11cGxvYWQnKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHZhciAkZWwgPSAkKHRoaXMpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faGFuZGxlcigkZWwsICdjbGljaycsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgJGZyYW1lID0gJGVsLmNsb3Nlc3QoJGguRlJBTUVTKSwgaW5kID0gJGZyYW1lLmF0dHIoJ2RhdGEtZmlsZWluZGV4Jyk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi4kcHJvZ3Jlc3MuaGlkZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICgkZnJhbWUuaGFzQ2xhc3MoJ2ZpbGUtcHJldmlldy1lcnJvcicpICYmICFzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fdXBsb2FkU2luZ2xlKGluZCwgZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRQcmV2aWV3QWN0aW9uczogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRwcmV2aWV3ID0gc2VsZi4kcHJldmlldywgZGVsZXRlRXh0cmFEYXRhID0gc2VsZi5kZWxldGVFeHRyYURhdGEgfHwge30sXHJcbiAgICAgICAgICAgICAgICBidG5SZW1vdmUgPSAkaC5GUkFNRVMgKyAnIC5rdi1maWxlLXJlbW92ZScsIHNldHRpbmdzID0gc2VsZi5maWxlQWN0aW9uU2V0dGluZ3MsXHJcbiAgICAgICAgICAgICAgICBvcmlnQ2xhc3MgPSBzZXR0aW5ncy5yZW1vdmVDbGFzcywgZXJyQ2xhc3MgPSBzZXR0aW5ncy5yZW1vdmVFcnJvckNsYXNzLFxyXG4gICAgICAgICAgICAgICAgcmVzZXRQcm9ncmVzcyA9IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgaGFzRmlsZXMgPSBzZWxmLmlzQWpheFVwbG9hZCA/IHNlbGYucHJldmlld0NhY2hlLmNvdW50KCkgOiBzZWxmLl9pbnB1dEZpbGVDb3VudCgpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmICghJHByZXZpZXcuZmluZCgkaC5GUkFNRVMpLmxlbmd0aCAmJiAhaGFzRmlsZXMpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2V0Q2FwdGlvbignJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYucmVzZXQoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5pbml0aWFsQ2FwdGlvbiA9ICcnO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRab29tQnV0dG9uKCk7XHJcbiAgICAgICAgICAgICRwcmV2aWV3LmZpbmQoYnRuUmVtb3ZlKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHZhciAkZWwgPSAkKHRoaXMpLCB2VXJsID0gJGVsLmRhdGEoJ3VybCcpIHx8IHNlbGYuZGVsZXRlVXJsLCB2S2V5ID0gJGVsLmRhdGEoJ2tleScpLFxyXG4gICAgICAgICAgICAgICAgICAgIGZuQmVmb3JlLCBmblN1Y2Nlc3MsIGZuRXJyb3I7XHJcbiAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eSh2VXJsKSB8fCB2S2V5ID09PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB2YXIgJGZyYW1lID0gJGVsLmNsb3Nlc3QoJGguRlJBTUVTKSwgY2FjaGUgPSBzZWxmLnByZXZpZXdDYWNoZS5kYXRhLFxyXG4gICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLCBwYXJhbXMsIGluZGV4ID0gJGZyYW1lLmF0dHIoJ2RhdGEtZmlsZWluZGV4JyksIGNvbmZpZywgZXh0cmFEYXRhO1xyXG4gICAgICAgICAgICAgICAgaW5kZXggPSBwYXJzZUludChpbmRleC5yZXBsYWNlKCdpbml0XycsICcnKSk7XHJcbiAgICAgICAgICAgICAgICBjb25maWcgPSAkaC5pc0VtcHR5KGNhY2hlLmNvbmZpZykgJiYgJGguaXNFbXB0eShjYWNoZS5jb25maWdbaW5kZXhdKSA/IG51bGwgOiBjYWNoZS5jb25maWdbaW5kZXhdO1xyXG4gICAgICAgICAgICAgICAgZXh0cmFEYXRhID0gJGguaXNFbXB0eShjb25maWcpIHx8ICRoLmlzRW1wdHkoY29uZmlnLmV4dHJhKSA/IGRlbGV0ZUV4dHJhRGF0YSA6IGNvbmZpZy5leHRyYTtcclxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZXh0cmFEYXRhID09PSAnZnVuY3Rpb24nKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZXh0cmFEYXRhID0gZXh0cmFEYXRhKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBwYXJhbXMgPSB7aWQ6ICRlbC5hdHRyKCdpZCcpLCBrZXk6IHZLZXksIGV4dHJhOiBleHRyYURhdGF9O1xyXG4gICAgICAgICAgICAgICAgZm5CZWZvcmUgPSBmdW5jdGlvbiAoanFYSFIpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmFqYXhBYm9ydGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVwcmVkZWxldGUnLCBbdktleSwganFYSFIsIGV4dHJhRGF0YV0pO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLl9hYm9ydCgpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGpxWEhSLmFib3J0KCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGVsLnJlbW92ZUNsYXNzKGVyckNsYXNzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGguYWRkQ3NzKCRmcmFtZSwgJ2ZpbGUtdXBsb2FkaW5nJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICRoLmFkZENzcygkZWwsICdkaXNhYmxlZCAnICsgb3JpZ0NsYXNzKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgZm5TdWNjZXNzID0gZnVuY3Rpb24gKGRhdGEsIHRleHRTdGF0dXMsIGpxWEhSKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdmFyIG4sIGNhcDtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoISRoLmlzRW1wdHkoZGF0YSkgJiYgISRoLmlzRW1wdHkoZGF0YS5lcnJvcikpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmpxWEhSID0ganFYSFI7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5yZXNwb25zZSA9IGRhdGE7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3Nob3dFcnJvcihkYXRhLmVycm9yLCBwYXJhbXMsICdmaWxlZGVsZXRlZXJyb3InKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGZyYW1lLnJlbW92ZUNsYXNzKCdmaWxlLXVwbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkZWwucmVtb3ZlQ2xhc3MoJ2Rpc2FibGVkICcgKyBvcmlnQ2xhc3MpLmFkZENsYXNzKGVyckNsYXNzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRQcm9ncmVzcygpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICRmcmFtZS5yZW1vdmVDbGFzcygnZmlsZS11cGxvYWRpbmcnKS5hZGRDbGFzcygnZmlsZS1kZWxldGVkJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGZyYW1lLmZhZGVPdXQoJ3Nsb3cnLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0gcGFyc2VJbnQoKCRmcmFtZS5hdHRyKCdkYXRhLWZpbGVpbmRleCcpKS5yZXBsYWNlKCdpbml0XycsICcnKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlLnVuc2V0KGluZGV4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fZGVsZXRlRmlsZUluZGV4KCRmcmFtZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBzZWxmLnByZXZpZXdDYWNoZS5jb3VudCgpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXAgPSBuID4gMCA/IHNlbGYuX2dldE1zZ1NlbGVjdGVkKG4pIDogJyc7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3NldENhcHRpb24oY2FwKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVkZWxldGVkJywgW3ZLZXksIGpxWEhSLCBleHRyYURhdGFdKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJGguY2xlYW5ab29tQ2FjaGUoJHByZXZpZXcuZmluZCgnI3pvb20tJyArICRmcmFtZS5hdHRyKCdpZCcpKSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyT2JqZWN0cygkZnJhbWUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAkZnJhbWUucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0UHJvZ3Jlc3MoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICBmbkVycm9yID0gZnVuY3Rpb24gKGpxWEhSLCB0ZXh0U3RhdHVzLCBlcnJvclRocm93bikge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciBvcCA9IHNlbGYuYWpheE9wZXJhdGlvbnMuZGVsZXRlVGh1bWIsIGVyck1zZyA9IHNlbGYuX3BhcnNlRXJyb3Iob3AsIGpxWEhSLCBlcnJvclRocm93bik7XHJcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmpxWEhSID0ganFYSFI7XHJcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zLnJlc3BvbnNlID0ge307XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fc2hvd0Vycm9yKGVyck1zZywgcGFyY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xpY2snLCBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLl92YWxpZGF0ZU1pbkNvdW50KCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmFqYXhBYm9ydGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGViZWZvcmVkZWxldGUnLCBbdktleSwgZXh0cmFEYXRhXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgLy9ub2luc3BlY3Rpb24gSlNVbnJlc29sdmVkVmFyaWFibGUsSlNIaW50XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGYuYWpheEFib3J0ZWQgaW5zdGFuY2VvZiBQcm9taXNlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuYWpheEFib3J0ZWQudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQuYWpheChzZXR0aW5ncyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VsZi5hamF4QWJvcnRlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5hamF4KHNldHRpbmdzKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9oaWRlRmlsZUljb246IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5vdmVyd3JpdGVJbml0aWFsKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyLnJlbW92ZUNsYXNzKCdpY29uLXZpc2libGUnKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3Nob3dGaWxlSWNvbjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgICRoLmFkZENzcyhzZWxmLiRjYXB0aW9uQ29udGFpbmVyLCAnaWNvbi12aXNpYmxlJyk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0U2l6ZTogZnVuY3Rpb24gKGJ5dGVzKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgc2l6ZSA9IHBhcnNlRmxvYXQoYnl0ZXMpLCBpLCBmdW5jID0gc2VsZi5maWxlU2l6ZUdldHRlciwgc2l6ZXMsIG91dDtcclxuICAgICAgICAgICAgaWYgKCEkLmlzTnVtZXJpYyhieXRlcykgfHwgISQuaXNOdW1lcmljKHNpemUpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gJyc7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHR5cGVvZiBmdW5jID09PSAnZnVuY3Rpb24nKSB7XHJcbiAgICAgICAgICAgICAgICBvdXQgPSBmdW5jKHNpemUpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaWYgKHNpemUgPT09IDApIHtcclxuICAgICAgICAgICAgICAgICAgICBvdXQgPSAnMC4wMCBCJztcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaSA9IE1hdGguZmxvb3IoTWF0aC5sb2coc2l6ZSkgLyBNYXRoLmxvZygxMDI0KSk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2l6ZXMgPSBbJ0InLCAnS0InLCAnTUInLCAnR0InLCAnVEInLCAnUEInLCAnRUInLCAnWkInLCAnWUInXTtcclxuICAgICAgICAgICAgICAgICAgICBvdXQgPSAoc2l6ZSAvIE1hdGgucG93KDEwMjQsIGkpKS50b0ZpeGVkKDIpICogMSArICcgJyArIHNpemVzW2ldO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgnc2l6ZScpLnJlcGxhY2UoJ3tzaXplVGV4dH0nLCBvdXQpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2dldEZpbGVUeXBlOiBmdW5jdGlvbiAoZnR5cGUpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gc2VsZi5taW1lVHlwZUFsaWFzZXNbZnR5cGVdIHx8IGZ0eXBlO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2dlbmVyYXRlUHJldmlld1RlbXBsYXRlOiBmdW5jdGlvbiAoXHJcbiAgICAgICAgICAgIGNhdCxcclxuICAgICAgICAgICAgZGF0YSxcclxuICAgICAgICAgICAgZm5hbWUsXHJcbiAgICAgICAgICAgIGZ0eXBlLFxyXG4gICAgICAgICAgICBwcmV2aWV3SWQsXHJcbiAgICAgICAgICAgIGlzRXJyb3IsXHJcbiAgICAgICAgICAgIHNpemUsXHJcbiAgICAgICAgICAgIGZyYW1lQ2xhc3MsXHJcbiAgICAgICAgICAgIGZvb3QsXHJcbiAgICAgICAgICAgIGluZCxcclxuICAgICAgICAgICAgdGVtcGwsXHJcbiAgICAgICAgICAgIGF0dHJzXHJcbiAgICAgICAgKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgY2Fw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uZWFjaChjb25maWcsIGZ1bmN0aW9uIChrZXksIHZhbCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlQXR0cmlicyArPSBrZXkgKyAnOicgKyB2YWwgKyAnOyc7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBnZXRDb250ZW50ID0gZnVuY3Rpb24gKGMsIGQsIHpvb20sIGZyYW1lQ3NzKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgaWQgPSB6b29tID8gJ3pvb20tJyArIHByZXZpZXdJZCA6IHByZXZpZXdJZCwgdG1wbHQgPSBzZWxmLl9nZXRQcmV2aWV3VGVtcGxhdGUoYyksXHJcbiAgICAgICAgICAgICAgICAgICAgY3NzID0gKGZyYW1lQ2xhc3MgfHwgJycpICsgJyAnICsgZnJhbWVDc3M7XHJcbiAgICAgICAgICAgICAgICBpZiAoc2VsZi5mcmFtZUNsYXNzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY3NzID0gc2VsZi5mcmFtZUNsYXNzICsgJyAnICsgY3NzO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKHpvb20pIHtcclxuICAgICAgICAgICAgICAgICAgICBjc3MgPSBjc3MucmVwbGFjZSgnICcgKyAkaC5TT1JUX0NTUywgJycpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdG1wbHQgPSBzZWxmLl9wYXJzZUZpbGVQcmV2aWV3SWNvbih0bXBsdCwgZm5hbWUpO1xyXG4gICAgICAgICAgICAgICAgaWYgKGMgPT09ICd0ZXh0Jykge1xyXG4gICAgICAgICAgICAgICAgICAgIGQgPSAkaC5odG1sRW5jb2RlKGQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGNhdCA9PT0gJ29iamVjdCcgJiYgIWZ0eXBlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgJC5lYWNoKHNlbGYuZGVmYXVsdHMuZmlsZVR5cGVTZXR0aW5ncywgZnVuY3Rpb24gKGtleSwgZnVuYykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSAnb2JqZWN0JyB8fCBrZXkgPT09ICdvdGhlcicpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZnVuYyhmbmFtZSwgZnR5cGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlQ3NzID0gJ3R5cGUtJyArIGtleTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKCEkaC5pc0VtcHR5KGF0dHJzKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhdHRycy50aXRsZSAhPT0gdW5kZWZpbmVkICYmIGF0dHJzLnRpdGxlICE9PSBudWxsKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gYXR0cnMudGl0bGU7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChhdHRycy5hbHQgIT09IHVuZGVmaW5lZCAmJiBhdHRycy5hbHQgIT09IG51bGwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSBhdHRycy5hbHQ7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRtcGx0LnNldFRva2Vucyh7XHJcbiAgICAgICAgICAgICAgICAgICAgJ3ByZXZpZXdJZCc6IGlkLFxyXG4gICAgICAgICAgICAgICAgICAgICdjYXB0aW9uJzogY2FwdGlvbixcclxuICAgICAgICAgICAgICAgICAgICAndGl0bGUnOiB0aXRsZSxcclxuICAgICAgICAgICAgICAgICAgICAnYWx0JzogYWx0LFxyXG4gICAgICAgICAgICAgICAgICAgICdmcmFtZUNsYXNzJzogY3NzLFxyXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogc2VsZi5fZ2V0RmlsZVR5cGUoZnR5cGUpLFxyXG4gICAgICAgICAgICAgICAgICAgICdmaWxlaW5kZXgnOiBpbmQsXHJcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbGVpZCc6IHNlbGYuX2dldEZpbGVJZHMoKVtpbmRdIHx8ICcnLFxyXG4gICAgICAgICAgICAgICAgICAgICd0eXBlQ3NzJzogdHlwZUNzcyxcclxuICAgICAgICAgICAgICAgICAgICAnZm9vdGVyJzogZm9vdGVyLFxyXG4gICAgICAgICAgICAgICAgICAgICdkYXRhJzogZCxcclxuICAgICAgICAgICAgICAgICAgICAndGVtcGxhdGUnOiB0ZW1wbCB8fCBjYXQsXHJcbiAgICAgICAgICAgICAgICAgICAgJ3N0eWxlJzogc3R5bGVBdHRyaWJzID8gJ3N0eWxlPVwiJyArIHN0eWxlQXR0cmlicyArICdcIicgOiAnJ1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIGluZCA9IGluZCB8fCBwcmV2aWV3SWQuc2xpY2UocHJldmlld0lkLmxhc3RJbmRleE9mKCctJykgKyAxKTtcclxuICAgICAgICAgICAgaWYgKHNlbGYuZmlsZUFjdGlvblNldHRpbmdzLnNob3dab29tKSB7XHJcbiAgICAgICAgICAgICAgICB6b29tQ29udGVudCA9IGdldENvbnRlbnQoKGZvcmNlWm9vbUljb24gPyAnb3RoZXInIDogY2F0KSwgZGF0YSwgdHJ1ZSwgJ2t2LXpvb20tdGh1bWInKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB6b29tQ29udGVudCA9ICdcXG4nICsgc2VsZi5fZ2V0TGF5b3V0VGVtcGxhdGUoJ3pvb21DYWNoZScpLnJlcGxhY2UoJ3t6b29tQ29udGVudH0nLCB6b29tQ29udGVudCk7XHJcbiAgICAgICAgICAgIHByZXZDb250ZW50ID0gZ2V0Q29udGVudCgoZm9yY2VQcmV2SWNvbiA/ICdvdGhlcicgOiBjYXQpLCBkYXRhLCBmYWxzZSwgJ2t2LXByZXZpZXctdGh1bWInKTtcclxuICAgICAgICAgICAgcmV0dXJuIHByZXZDb250ZW50ICsgem9vbUNvbnRlbnQ7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfYWRkVG9QcmV2aWV3OiBmdW5jdGlvbiAoJHByZXZpZXcsIGNvbnRlbnQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gc2VsZi5yZXZlcnNlUHJldmlld09yZGVyID8gJHByZXZpZXcucHJlcGVuZChjb250ZW50KSA6ICRwcmV2aWV3LmFwcGVuZChjb250ZW50KTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9wcmV2aWV3RGVmYXVsdDogZnVuY3Rpb24gKGZpbGUsIHByZXZpZXdJZCwgaXNEaXNhYmxlZCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRwcmV2aWV3ID0gc2VsZi4kcHJldmlldztcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdmFyIGZuYW1lID0gJGguZ2V0RmlsZU5hbWUoZmlsZSksIGZ0eXBlID0gZmlsZSA/IGZpbGUudHlwZSA6ICcnLCBjb250ZW50LCBzaXplID0gZmlsZS5zaXplIHx8IDAsXHJcbiAgICAgICAgICAgICAgICBjYXB0aW9uID0gc2VsZi5zbHVnKGZuYW1lKSwgaXNFcnJvciA9IGlzRGlzYWJsZWQgPT09IHRydWUgJiYgIXNlbGYuaXNBamF4VXBsb2FkL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gICAgICAgICAgICAgdmFyICRpbWcgPSAkcHJldmlldy5maW5kKCcjJyArIHByZXZpZXdJZCArICcgaW1nJyk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl92YWxpZGF0ZUltYWdlT3JpZW50YXRpb24oJGltZywgZmlsZSwgcHJldmlld0lkLCBjYXB0aW9uLCBmdHlwZSwgZnNpemUsIGlEYXRhKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3ByZXZpZXdEZWZhdWx0KGZpbGUsIHByZXZpZXdJZCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fc2V0VGh1bWJBdHRyKHByZXZpZXdJZCwgY2FwdGlvbiwgZnNpemUpO1xyXG4gICAgICAgICAgICBzZWxmLl9pbml0U29ydGFibGUoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9zZXRUaHVtYkF0dHI6IGZ1bmN0aW9uIChpZCwgY2FwdGlvbiwgc2l6ZSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRmcmFtZSA9ICQoJyMnICsgaWQpO1xyXG4gICAgICAgICAgICBpZiAoJGZyYW1lLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgc2l6ZSA9IHNpemUgJiYgc2l6ZSA+IDAgPyBzZWxmLl9nZXRTaXplKHNpemUpIDogJyc7XHJcbiAgICAgICAgICAgICAgICAkZnJhbWUuZGF0YSh7J2NhcHRpb24nOiBjYXB0aW9uLCAnc2l6ZSc6IHNpemV9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3NldEluaXRUaHVtYkF0dHI6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBkYXRhID0gc2VsZi5wcmV2aWV3Q2FjaGUuZGF0YSwgbGVuID0gc2VsZi5wcmV2aWV3Q2FjaGUuY291bnQoKSwgY29uZmlnLFxyXG4gICAgICAgICAgICAgICAgY2FwdGlvbiwgc2l6ZSwgcHJldmlld0lkO1xyXG4gICAgICAgICAgICBpZiAobGVuID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY29uZmlnID0gZGF0YS5jb25maWdbaV07XHJcbiAgICAgICAgICAgICAgICBwcmV2aWV3SWQgPSBzZWxmLnByZXZpZXdJbml0SWQgKyAnLScgKyAnaW5pdF8nICsgaTtcclxuICAgICAgICAgICAgICAgIGNhcHRpb24gPSAkaC5pZlNldCgnY2FwdGlvbicsIGNvbmZpZywgJGguaWZTZXQoJ2ZpbGVuYW1lJywgY29uZmlnKSk7XHJcbiAgICAgICAgICAgICAgICBzaXplID0gJGguaWZTZXQoJ3NpemUnLCBjb25maWcpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fc2V0VGh1bWJBdHRyKHByZXZpZXdJZCwgY2FwdGlvbiwgc2l6ZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9zbHVnRGVmYXVsdDogZnVuY3Rpb24gKHRleHQpIHtcclxuICAgICAgICAgICAgLy8gbm9pbnNwZWN0aW9uIFJlZ0V4cFJlZHVuZGFudEVzY2FwZVxyXG4gICAgICAgICAgICByZXR1cm4gJGguaXNFbXB0eSh0ZXh0KSA/ICcnIDogU3RyaW5nKHRleHQpLnJlcGxhY2UoL1tcXFtcXF1cXC9cXHt9OjsjJT1cXChcXClcXCpcXCtcXD9cXFxcXFxeXFwkXFx8PD4mXCInXS9nLCAnXycpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3VwZGF0ZUZpbGVEZXRhaWxzOiBmdW5jdGlvbiAobnVtRmlsZXMpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZWwgPSB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bW92ZUNsYXNzKCdmaWxlLWlucHV0LW5ldyBmaWxlLWlucHV0LWFqYXgtbmV3Jyk7XHJcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID09PSAxKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZXNlbGVjdCcsIFtudW1GaWxlcywgbGFiZWxdKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoc2VsZi5wcmV2aWV3Q2FjaGUuY291bnQoKSkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFByZXZpZXdBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9zZXRUaHVtYlN0YXR1czogZnVuY3Rpb24gKCR0aHVtYiwgc3RhdHVzKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdmFyIGljb24gPSAnaW5kaWNhdG9yJyArIHN0YXR1cywgbXNnID0gaWNvbiArICdUaXRsZScsXHJcbiAgICAgICAgICAgICAgICBjc3MgPSAnZmlsZS1wcmV2aWV3LScgKyBzdGF0dXMudG9Mb3dlckNhc2UoKSxcclxuICAgICAgICAgICAgICAgICRpbmRpY2F0b3IgPSAkdGh1bWIuZmluZCgnLmZpbGUtdXBsb2FkLWluZGljYXRvcicpLFxyXG4gICAgICAgICAgICAgICAgY29uZmlnID0gc2VsZi5maWxlQWN0aW9uU2V0dGluZ3M7XHJcbiAgICAgICAgICAgICR0aHVtYi5yZW1vdmVDbGFzcygnZmlsZS1wcmV2aWV3LXN1Y2Nlc3MgZmlsZS1wcmV2aWV3LWVycm9yIGZpbGUtcHJldmlldy1sb2FkaW5nJyk7XHJcbiAgICAgICAgICAgIGlmIChzdGF0dXMgPT09ICdTdWNjZXNzJykge1xyXG4gICAgICAgICAgICAgICAgJHRodW1iLmZpbmQoJy5maWxlLWRyYWctaGFuZGxlJykucmVtb3ZlKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGluZGljYXRvci5odG1sKGNvbmZpZ1tpY29uXSk7XHJcbiAgICAgICAgICAgICRpbmRpY2F0b3IuYXR0cigndGl0bGUnLCBjb25maWdbbXNnXSk7XHJcbiAgICAgICAgICAgICR0aHVtYi5hZGRDbGFzcyhjc3MpO1xyXG4gICAgICAgICAgICBpZiAoc3RhdHVzID09PSAnRXJyb3InICYmICFzZWxmLnJldHJ5RXJyb3JVcGxvYWRzKSB7XHJcbiAgICAgICAgICAgICAgICAkdGh1bWIuZmluZCgnLmt2LWZpbGUtdXBsb2FkJykuYXR0cignZGlzYWJsZWQnLCB0cnVlKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3NldFByb2dyZXNzQ2FuY2VsbGVkOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMTAxLCBzZWxmLiRwcm9ncmVzcywgc2VsZi5tc2dDYW5jZWxsZWQpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3NldFByb2dyZXNzOiBmdW5jdGlvbiAocCwgJGVsLCBlcnJvcikge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHBjdCA9IE1hdGgubWluKHAsIDEwMCksIG91dCwgcGN0TGltaXQgPSBzZWxmLnByb2dyZXNzVXBsb2FkVGhyZXNob2xkLFxyXG4gICAgICAgICAgICAgICAgdCA9IHAgPD0gMTAwID8gc2VsZi5wcm9ncmVzc1RlbXBsYXRlIDogc2VsZi5wcm9ncmVzc0NvbXBsZXRlVGVtcGxhdGUsXHJcbiAgICAgICAgICAgICAgICB0ZW1wbGF0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5kcm9wWm9uZVRpdGxlLCBzdHJGaWxlcztcclxuICAgICAgICAgICAgaWYgKHNlbGYuaXNDbGlja2FibGUpIHtcclxuICAgICAgICAgICAgICAgIHN0ckZpbGVzID0gJGguaXNFbXB0eShzZWxmLiRlbGVtZW50LmF0dHIoJ211bHRpcGxlJykpID8gc2VsZi5maWxlU2luZ2xlIDogc2VsZi5maWxlUGx1cmFsO1xyXG4gICAgICAgICAgICAgICAgdGl0bGUgKz0gc2VsZi5kcm9wWm9uZUNsaWNrVGl0bGUucmVwbGFjZSgne2ZpbGVzfScsIHN0ckZpbGVzKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkem9uZS5maW5kKCcuJyArIHNlbGYuZHJvcFpvbmVUaXRsZUNsYXNzKS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3IHx8ICR6b25lLmxlbmd0aCA9PT0gMCB8fCBzZWxmLmdldEZpbGVTdGFjaygpLmxlbmd0aCA+IDAgfHwgIXNlbGYuZHJvcFpvbmVFbmFibGVkIHx8XHJcbiAgICAgICAgICAgICAgICAoIXNlbGYuaXNBamF4VXBsb2FkICYmIHNlbGYuJGVsZW1lbnQuZmlsZXMpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCR6b25lLmZpbmQoJGguRlJBTUVTKS5sZW5ndGggPT09IDAgJiYgJGguaXNFbXB0eShzZWxmLmRlZmF1bHRQcmV2aWV3Q29udGVudCkpIHtcclxuICAgICAgICAgICAgICAgICR6b25lLnByZXBlbmQoJzxkaXYgY2xhc3M9XCInICsgc2VsZi5kcm9wWm9uZVRpdGxlQ2xhc3MgKyAnXCI+JyArIHRpdGxlICsgJzwvZGl2PicpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuJGNvbnRhaW5lci5yZW1vdmVDbGFzcygnZmlsZS1pbnB1dC1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XNFcnJvcih7fSk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZ2V0RmlsZUNvdW50OiBmdW5jdGlvbiAoZmlsZUNvdW50KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgYWRkQ291bnQgPSAwO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi52YWxpZGF0ZUluaXRpYWxDb3VudCAmJiAhc2VsZi5vdmVyd3JpdGVJbml0aWFsKSB7XHJcbiAgICAgICAgICAgICAgICBhZGRDb3VudCA9IHNlbGYucHJldmlld0NhY2hlLmNvdW50KCk7XHJcbiAgICAgICAgICAgICAgICBmaWxlQ291bnQgKz0gYWRkQ291bnQ7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGZpbGVDb3VudDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9nZXRGaWxlSWQ6IGZ1bmN0aW9uIChmaWxlKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgY3VzdG9tID0gc2VsZi5nZW5lcmF0ZUZpbGVJZCwgcmVsYXRpdmVQYXRoO1xyXG4gICAgICAgICAgICBpZiAodHlwZW9mIGN1c3RvbSA9PT0gJ2Z1bmN0aW9uJykge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGN1c3RvbShmaWxlLCBldmVudCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCFmaWxlKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBmaWxlLnJlbGF0aXZlUGF0aCAqL1xyXG4gICAgICAgICAgICAvKiogQG5hbWVzcGFjZSBmaWxlLndlYmtpdFJlbGF0aXZlUGF0aCAqL1xyX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RoaXM7XHJcbiAgICAgICAgICAgIHJldHVybiBzZWxmLmZpbGVuYW1lcy5maWx0ZXIoZnVuY3Rpb24gKG4pIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiAoc2tpcE51bGwgPyBuICE9PSB1bmRlZmluZWQgOiBuICE9PSB1bmRlZmluZWQgJiYgbiAhPT0gbnVsbCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3NldFByZXZpZXdFcnJvcjogZnVuY3Rpb24gKCR0aHVtYiwgaSwgdmFsLCByZXBlYXQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoaSAhPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnVwZGF0ZVN0YWNrKGksIHZhbCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dQcmV2aWV3KSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHNlbGYucmVtb3ZlRnJvbVByZXZpZXdPbkVycm9yICYmICFyZXBlYXQpIHtcclxuICAgICAgICAgICAgICAgICR0aHVtYi5yZW1vdmUoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3NldFRodW1iU3RhdHVzKCR0aHVtYiwgJ0Vycm9yJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fcmVmcmVzaFVwbG9hZEJ1dHRvbigkdGh1bWIsIHJlcGVhdCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVmcmVzaFVwbG9hZEJ1dHRvbjogZnVuY3Rpb24gKCR0aHVtYiwgcmVwZWF0KSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGJ0biA9ICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKSwgY2ZnID0gc2VsZi5maWxlQWN0aW9uU2V0dGluZ3MsXHJcbiAgICAgICAgICAgICAgICBpY29uID0gY2ZnLnVwbG9hZEljb24sIHRpdGxlID0gY2ZnLnVwbG9hZFRpdGxlO1xyXG4gICAgICAgICAgICBpZiAoISRidG4ubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHJlcGVhdCkge1xyXG4gICAgICAgICAgICAgICAgaWNvbiA9IGNmZy51cGxvYWRSZXRyeUljb247XHJcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGNmZy51cGxvYWRSZXRyeVRpdGxlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICRidG4uYXR0cigndGl0bGUnLCB0aXRsZSkuaHRtbChpY29uKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9jaGVja0RpbWVuc2lvbnM6IGZ1bmN0aW9uIChpLCBjaGssICRpbWcsICR0aHVtYiwgZm5hbWUsIHR5cGUsIHBhcmFtcykge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIG1zZywgZGltLCB0YWcgPSBjaGsgPT09ICdTbWFsbCcgPyAnbWluJyA6ICdtYXgnLCBsaW1pdCA9IHNlbGZbdGFnICsgJ0ltYWdlJyArIHR5cGVdLFxyXG4gICAgICAgICAgICAgICAgJGltZ0VsLCBpc1ZhbGlkO1xyXG4gICAgICAgICAgICBpZiAoJGguaXNFbXB0eShsaW1pdCkgfHwgISRpbWcubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGltZ0VsID0gJGltZ1swXTtcclxuICAgICAgICAgICAgZGltID0gKHR5cGUgPT09ICdXaWR0aCcpID8gJGltZ0VsLm5hdHVyYWxXaWR0aCB8fCAkaW1nRWwud2lkdGggOiAkaW1nRWwubmF0dXJhbEhlaWdodCB8fCAkaW1nRWwuaGVpZ2h0O1xyXG4gICAgICAgICAgICBpc1ZhbGlkID0gY2hrID09PSAnU21hbGwnID8gZGltID49IGxpbWl0IDogZGltIDw9IGxpbWl0O1xyXG4gICAgICAgICAgICBpZiAoaXNWYWxpZCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIG1zZyA9IHNlbGZbJ21zZ0ltYWdlJyArIHR5cGUgKyBjaGtdLnNldFRva2Vucyh7J25hbWUnOiBmbmFtZSwgJ3NpemUnOiBsaW1pdH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9zaG93VXBsb2FkRXJyb3IobXNnLCBwYXJhbXMpO1xyXG4gICAgICAgICAgICBzZWxmLl9zZXRQcmV2aWV3RXJyb3IoJHRodW1iLCBpLCBudWxsKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF9nZXRFeGlmT2JqOiBmdW5jdGlvbiAoZGF0YSkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGV4aWZPYmogPSBudWxsO1xyXG4gICAgICAgICAgICBpZiAoZGF0YS5zbGljZSgwLCAyMykgIT09ICdkYXRhOmltYWdlL2pwZWc7YmFzZTY0LCcgJiYgZGF0YS5zbGljZSgwLCAyMikgIT09ICdkYXRhOmltYWdlL2pwZztiYXNlNjQsJykge1xyXG4gICAgICAgICAgICAgICAgZXhpZk9iaiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIGV4aWZPYmogPSB3aW5kb3cucGlleGlmID8gd2luZG93LnBpZXhpZi5sb2FkKGRhdGEpIDogbnVsbDtcclxuXHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xyXG4gICAgICAgICAgICAgICAgZXhpZk9iaiA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9sb2coZXJyKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoIWV4aWZPYmopIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2xvZyhcclxuICAgICAgICAgICAgICAgICAgICAnVGhlIHBpZXhpZi5qcyBsaWJyYXJ5IHdhcyBub3QgZGV0ZWN0ZWQuIEVpdGhlciBsb2FkIHBpZXhpZi5qcyBvbiB5b3VyIHBhZ2UgT1Igc2V0IGBhdXRvT3JpZW50SW1hZ2VgIHRvIGBmYWxzZWAuJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIGV4aWZPYmo7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfdmFsaWRhdGVJbWFnZU9yaWVudGF0aW9uOiBmdW5jdGlvbiAoJGltZywgZmlsZSwgcHJldmlld0lkLCBjYXB0aW9uLCBmdHlwZSwgZnNpemUsIGlEYXRhKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgZXhpZk9iaiwgdmFsdWUsIGF1dG9PcmllbnRJbWFnZSA9IHNlbGYuYXV0b09yaWVudEltYWdlO1xyXG4gICAgICAgICAgICBpZiAodHlwZW9mIGF1dG9PcmllbnRJbWFnZSA9PT0gJ2Z1bmN0aW9uJykge1xyXG4gICAgICAgICAgICAgICAgYXV0b09yaWVudEltYWdlID0gYXV0b09yaWVudEltYWdlKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZXhpZk9iaiA9ICRpbWcubGVuZ3RoICYmIGF1dG9PcmllbnRJbWFnZSA/IHNlbGYuX2dldEV4aWZPYmooaURhdGEpIDogbnVsbDtcclxuICAgICAgICAgICAgdmFsdWUgPSBleGlmT2JqID8gZXhpZk9ialsnMHRoJ11bcGlleGlmLkltYWdlSUZELk9yaWVudGF0aW9uXSA6IG51bGw7IC8vIGpzaGludCBpZ25vcmU6b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ICB3MSA9ICR0aHVtYi53aWR0aCgpO1xyXG4gICAgICAgICAgICAgICAgdzIgPSAkcHJldmlldy53aWR0aCgpO1xyXG4gICAgICAgICAgICAgICAgaWYgKHcxID4gdzIpIHtcclxuICAgICAgICAgICAgICAgICAgICAkaW1nLmNzcygnd2lkdGgnLCAnMTAwJScpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgcGFyYW1zID0ge2luZDogaSwgaWQ6IHByZXZpZXdJZH07XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9jaGVja0RpbWVuc2lvbnMoaSwgJ1NtYWxsJywgJGltZywgJHRodW1iLCBmbmFtZSwgJ1dpZHRoJywgcGFyYW1zKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2NoZWNrRGltZW5zaW9ucyhpLCAnU21hbGwnLCAkaW1nLCAkdGh1bWIsIGZuYW1lLCAnSGVpZ2h0JywgcGFyYW1zKTtcclxuICAgICAgICAgICAgICAgIGlmICghc2VsZi5yZXNpemVJbWFnZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2NoZWNrRGltZW5zaW9ucyhpLCAnTGFyZ2UnLCAkaW1nLCAkdGh1bWIsIGZuYW1lLCAnV2lkdGgnLCBwYXJhbXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2NoZWNrRGltZW5zaW9ucyhpLCAnTGFyZ2UnLCAkaW1nLCAkdGh1bWIsIGZuYW1lLCAnSGVpZ2h0JywgcGFyYW1zKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlaW1hZ2Vsb2FkZWQnLCBbcHJldmlld0lkXSk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmxvYWRlZEltYWdlcy5wdXNoKHtcclxuICAgICAgICAgICAgICAgICAgICBpbmQ6IGksXHJcbiAgICAgICAgICAgICAgICAgICAgaW1nOiAkaW1nLFxyXG4gICAgICAgICAgICAgICAgICAgIHRodW1iOiAkdGh1bWIsXHJcbiAgICAgICAgICAgICAgICAgICAgcGlkOiBwcmV2aWV3SWQsXHJcbiAgICAgICAgICAgICAgICAgICAgdHlwOiBmdHlwZSxcclxuICAgICAgICAgICAgICAgICAgICBzaXo6IGZzaXplLFxyXG4gICAgICAgICAgICAgICAgICAgIHZhbGlkYXRlZDogZmFsc2UsXHJcbiAgICAgICAgICAgICAgICAgICAgaW1nRGF0YTogaURhdGEsXHJcbiAgICAgICAgICAgICAgICAgICAgZXhpZk9iajogZXhpZk9ialxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAkdGh1bWIuZGF0YSgnZXhpZicsIGV4aWZPYmopO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fdmFsaWRhdGVBbGxJbWFnZXMoKTtcclxuICAgICAgICAgICAgfSkub25lKCdlcnJvcicsIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlaW1hZ2Vsb2FkZXJyb3InLCBbcHJldmlld0lkXSk7XHJcbiAgICAgICAgICAgIH0pLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuY29tcGxldGUpIHtcclxuICAgICAgICAgICAgICAgICAgICAkKHRoaXMpLnRyaWdnZXIoJ2xvYWQnKTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZXJyb3IpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJCh0aGlzKS50cmlnZ2VyKCdlcnJvcicpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfdmFsaWRhdGVBbGxJbWFnZXM6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBpLCBjb3VudGVyID0ge3ZhbDogMH0sIG51bUltZ3MgPSBzZWxmLmxvYWRlZEltYWdlcy5sZW5ndGgsIGNvbmZpZyxcclxuICAgICAgICAgICAgICAgIGZzaXplLCBtaW5TaXplID0gc2VsZi5yZXNpemVJZlNpemVNb3JlVGhhbjtcclxuICAgICAgICAgICAgaWYgKG51bUltZ3MgIT09IHNlbGYudG90YWxJbWFnZXNDb3VudCkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlaW1hZ2VzbG9hZGVkJyk7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5yZXNpemVJbWFnZSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBzZWxmLmxvYWRlZEltYWdlcy5sZW5ndGg7IGkrKykge1xyXG4gICAgICAgICAgICAgICAgY29uZmlnID0gc2VsZi5sb2FkZWRJbWFnZXNbaV07XHJcbiAgICAgICAgICAgICAgICBpZiAoY29uZmlnLnZhbGlkYXRlZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgZnNpemUgPSBjb25maWcuc2l6O1xyXG4gICAgICAgICAgICAgICAgaWYgKGZzaXplICYmIGZzaXplID4gbWluU2l6ZSAqIDEwMDApIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9nZXRSZXNpemVkSW1hZ2UoY29uZmlnLCBjb3VudGVyLCBudW1JbWdzKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYubG9hZGVkSW1hZ2VzW2ldLnZhbGlkYXRlZCA9IHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9nZ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zZywgcGFyYW1zLCBldik7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zZXRQcmV2aWV3RXJyb3IoJHRodW1iLCBpbmQpO1xyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuZmlsZXN0YWNrW2luZF0gfHwgIWlzVmFsaWRJbWFnZSB8fCAod2lkdGggPD0gbWF4V2lkdGggJiYgaGVpZ2h0IDw9IG1heEhlaWdodCkpIHtcclxuICAgICAgICAgICAgICAgIGlmIChpc1ZhbGlkSW1hZ2UgJiYgc2VsZi5maWxlc3RhY2tbaW5kXSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlaW1hZ2VyZXNpemVkJywgW3BpZCwgaW5kXSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjb3VudGVyLnZhbCsrO1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvdW50ZXIudmFsID09PSBudW1JbWdzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVpbWFnZXNyZXNpemVkJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoIWlzVmFsaWRJbWFnZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3Ioc2VsZi5tc2dJbWFnZVJlc2l6ZUVycm9yLCB7aWQ6IHBpZCwgJ2luZGV4JzogaW5kfSwgJ2ZpbGVpbWFnZXJlc2l6ZWVycm9yJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHR5cGUgPSB0eXBlIHx8IHNlbGYucmVzaXplRGVmYXVsdEltYWdlVHlwZTtcclxuICAgICAgICAgICAgY2hrV2lkdGggPSB3aWR0aCA+IG1heFdpZHRoO1xyXG4gICAgICAgICAgICBjaGtIZWlnaHQgPSBoZWlnaHQgPiBtYXhIZWlnaHQ7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc2l6ZVByZWZlcmVuY2UgPT09ICd3aWR0aCcpIHtcclxuICAgICAgICAgICAgICAgIHJhdGlvID0gY2hrV2lkdGggPyBtYXhXaWR0aCAvIHdpZHRoIDogKGNoa0hlaWdodCA/IG1heEhlaWdodCAvIGhlaWdodCA6IDEpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgcmF0aW8gPSBjaGtIZWlnaHQgPyBtYXhIZWlnaHQgLyBoZWlnaHQgOiAoY2hrV2lkdGggPyBtYXhXaWR0aCAvIHdpZHRoIDogMSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fcmVzZXRDYW52YXMoKTtcclxuICAgICAgICAgICAgd2lkdGggKj0gcmF0aW87XHJcbiAgICAgICAgICAgIGhlaWdodCAqPSByYXRpbztcclxuICAgICAgICAgICAgY2FudmFzLndpZHRoID0gd2lkdGg7XHJcbiAgICAgICAgICAgIGNhbnZhcy5oZWlnaHQgPSBoZWlnaHQ7XHJcbiAgICAgICAgICAgIHRyeSB7XHJcbiAgICAgICAgICAgICAgICBjb250ZXh0LmRyYXdJbWFnZShpbWcsIDAsIDAsIHdpZHRoLCBoZWlnaHQpO1xyXG4gICAgICAgICAgICAgICAgZGF0YVVSSSA9IGNhbnZhcy50b0RhdGFVUkwodHlwZSwgc2VsZi5yZXNpemVRdWFsaXR5KTtcclxuICAgICAgICAgICAgICAgIGlmIChleGlmT2JqKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZXhpZlN0ciA9IHdpbmRvdy5waWV4aWYuZHVtcChleGlmT2JqKTtcclxuICAgICAgICAgICAgICAgICAgICBkYXRhVVJJID0gd2luZG93LnBpZXhpZi5pbnNlcnQoZXhpZlN0ciwgZGF0YVVSSSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBibG9iID0gJGguZGF0YVVSSTJCbG9iKGRhdGFVUkkpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5maWxlc3RhY2tbaW5kXSA9IGJsb2I7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWltYWdlcmVzaXplZCcsIFtwaWQsIGluZF0pO1xyXG4gICAgICAgICAgICAgICAgY291bnRlci52YWwrKztcclxuICAgICAgICAgICAgICAgIGlmIChjb3VudGVyLnZhbCA9PT0gbnVtSW1ncykge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlaW1hZ2VzcmVzaXplZCcsIFt1bmRlZmluZWQsIHVuZGVmaW5lZF0pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKCEoYmxvYiBpbnN0YW5jZW9mIEJsb2IpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcihzZWxmLm1zZ0ltYWdlUmVzaXplRXJyb3IsIHtpZDogcGlkLCAnaW5kZXgnOiBpbmR9LCAnZmlsZWltYWdlcmVzaXplZXJyb3InKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XHJcbiAgICAgICAgICAgICAgICBjb3VudGVyLnZhbCsrO1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvdW50ZXIudmFsID09PSBudW1JbWdzKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVpbWFnZXNyZXNpemVkJywgW3VuZGVmaW5lZCwgdW5kZWZpbmVkXSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBtc2cgPSBzZWxmLm1zZ0ltYWdlUmVzaXplRXhjZXB0aW9uLnJlcGxhY2UoJ3tlcnJvcnN9JywgZXJyLm1lc3NhZ2UpO1xyXG4gICAgICAgICAgICAgICAgdGhyb3dFcnJvcihtc2csIHtpZDogcGlkLCAnaW5kZXgnOiBpbmR9LCAnZmlsZWltYWdlcmVzaXplZXhjZXB0aW9uJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9pbml0QnJvd3NlOiBmdW5jdGlvbiAoJGNvbnRhaW5lcikge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRlbCA9IHNlbGYuJGVsZW1lbnQ7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnNob3dCcm93c2UpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuJGJ0bkZpbGUgPSAkY29udGFpbmVyLmZpbmQoJy5idG4tZmlsZScpLmFwcGVuZCgkZWwpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgJGVsLmFwcGVuZFRvKCRjb250YWluZXIpLmF0dHIoJ3RhYmluZGV4JywgLTEpO1xyXG4gICAgICAgICAgICAgICAgJGguYWRkQ3NzKCRlbCwgJ2ZpbGUtbm8tYnJvd3NlJyk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9pbml0Q2xpY2thYmxlOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJHpvbmUsICR0bXBab25lO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuaXNDbGlja2FibGUpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAkem9uZSA9IHNlbGYuJGRyb3Bab25lO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICAkdG1wWm9uZSA9IHNlbGYuJHByZXZpZXcuZmluZCgnLmZpbGUtZGVmYXVsdC1wcmV2aWV3Jyk7XHJcbiAgICAgICAgICAgICAgICBpZiAoJHRtcFpvbmUubGVuZ3RoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgJHpvbmUgPSAkdG1wWm9uZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgJGguYWRkQ3NzKCR6b25lLCAnY2xpY2thYmxlJyk7XHJcbiAgICAgICAgICAgICR6b25lLmF0dHIoJ3RhYmluZGV4JywgLTEpO1xyXG4gICAgICAgICAgICBzZWxmLl9oYW5kbGVyKCR6b25lLCAnY2xpY2snLCBmdW5jdGlvbiAoZSkge1xyXG4gICAgICAgICAgICAgICAgdmFyICR0YXIgPSAkKGUudGFyZ2V0KTtcclxuICAgICAgICAgICAgICAgIGlmICghJChzZWxmLmVsRXJyb3JDb250YWluZXIgKyAnOnZpc2libGUnKS5sZW5ndGggJiZcclxuICAgICAgICAgICAgICAgICAgICAoISR0YXIucGFyZW50cygnLmZpbGUtcHJldmlldy10aHVtYm5haWxzJykubGVuZ3RoIHx8ICR0YXIucGFyZW50cyhcclxuICAgICAgICAgICAgICAgICAgICAgICAgJy5maWxlLWRlZmF1bHQtcHJldmlldycpLmxlbmd0aCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLiRlbGVtZW50LmRhdGEoJ3pvbmVDbGlja2VkJywgdHJ1ZSkudHJpZ2dlcignY2xpY2snKTtcclxuICAgICAgICAgICAgICAgICAgICAkem9uZS5ibHVyKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2luaXRDYXB0aW9uOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgY2FwID0gc2VsZi5pbml0aWFsQ2FwdGlvbiB8fCAnJztcclxuICAgICAgICAgICAgaWYgKHNlbGYub3ZlcndyaXRlSW5pdGlhbCB8fCAkaC5pc0VtcHR5KGNhcCkpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuJGNhcHRpb24udmFsKCcnKTtcclxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl9zZXRDYXB0aW9uKGNhcCk7XHJcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX3NldENhcHRpb246IGZ1bmN0aW9uIChjb250ZW50LCBpc0Vycm9yKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgdGl0bGUsIG91dCwgaWNvbiwgbiwgY2FwLCBzdGFjayA9IHNlbGYuZ2V0RmlsZVN0YWNrKCk7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi4kY2FwdGlvbi5sZW5ndGgpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyLnJlbW92ZUNsYXNzKCdpY29uLXZpc2libGUnKTtcclxuICAgICAgICAgICAgaWYgKGlzRXJyb3IpIHtcclxuICAgICAgICAgICAgICAgIHRpdGxlID0gJCgnPGRpdj4nICsgc2VsZi5tc2dWYWxpZGF0aW9uRXJyb3IgKyAnPC9kaXY+JykudGV4dCgpO1xyXG4gICAgICAgICAgICAgICAgbiA9IHN0YWNrLmxlbmd0aDtcclxuICAgICAgICAgICAgICAgIGlmIChuKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgY2FwID0gbiA9PT0gMSAmJiBzdGFja1swXSA/IHNlbGYuX2dldEZpbGVOYW1lcygpWzBdIDogc2VsZi5fZ2V0TXNnU2VsZWN0ZWQobik7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIGNhcCA9IHNlbGYuX2dldE1zZ1NlbGVjdGVkKHNlbGYubXNnTm8pO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgb3V0ID0gJGguaXNFbXB0eShjb250ZW50KSA/IGNhcCA6IGNvbnRlbnQ7XHJcbiAgICAgICAgICAgICAgICBpY29uID0gJzxzcGFuIGNsYXNzPVwiJyArIHNlbGYubXNnVmFsaWRhdGlvbkVycm9yQ2xhc3MgKyAnXCI+JyArIHNlbGYubXNnVmFsaWRhdGlvbkVycm9ySWNvbiArICc8L3NwYW4+JztcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlmICgkaC5pc0VtcHR5KGNvbnRlbnQpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdGl0bGUgPSAkKCc8ZGl2PicgKyBjb250ZW50ICsgJzwvZGl2PicpLnRleHQoKTtcclxuICAgICAgICAgICAgICAgIG91dCA9IHRpdGxlO1xyXG4gICAgICAgICAgICAgICAgaWNvbiA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdmaWxlSWNvbicpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuJGNhcHRpb25Db250YWluZXIuYWRkQ2xhc3MoJ2ljb24tdmlzaWJsZScpO1xyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uLmF0dHIoJ3RpdGxlJywgdGl0bGUpLnZhbChvdXQpO1xyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uSWNvbi5odG1sKGljb24pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIGF0dHJpYnMgPSB7J2NsYXNzJzogJ2ZpbGUtaW5wdXQgZmlsZS1pbnB1dC1uZXcnICsgKHNlbGYucnRsID8gJyBrdi1ydGwnIDogJycpfSxcclxuICAgICAgICAgICAgICAgICRjb250YWluZXIgPSAkKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpKS5hdHRyKGF0dHJpYnMpLmh0bWwoc2VsZi5fcmVuZGVyTWFpbigpKTtcclxuICAgICAgICAgICAgJGNvbnRhaW5lci5pbnNlcnRCZWZvcmUoc2VsZi4kZWxlbWVudCk7XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRCcm93c2UoJGNvbnRhaW5lcik7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnRoZW1lKSB7XHJcbiAgICAgICAgICAgICAgICAkY29udGFpbmVyLmFkZENsYXNzKCd0aGVtZS0nICsgc2VsZi50aGVtZSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuICRjb250YWluZXI7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVmcmVzaENvbnRhaW5lcjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsICRjb250YWluZXIgPSBzZWxmLiRjb250YWluZXIsICRlbCA9IHNlbGYuJGVsZW1lbnQ7XHJcbiAgICAgICAgICAgICRlbC5pbnNlcnRBZnRlcigkY29udGFpbmVyKTtcclxuICAgICAgICAgICAgJGNvbnRhaW5lci5odG1sKHNlbGYuX3JlbmRlck1haW4oKSk7XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRCcm93c2UoJGNvbnRhaW5lcik7XHJcbiAgICAgICAgICAgIHNlbGYuX3ZhbGlkYXRlRGlzYWJsZWQoKTtcclxuICAgICAgICB9LFxyXG4gICAgICAgIF92YWxpZGF0ZURpc2FibGVkOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcclxuICAgICAgICAgICAgc2VsZi4kY2FwdGlvbi5hdHRyKHtyZWFkb25seTogc2VsZi5pc0Rpc2FibGVkfSk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVuZGVyTWFpbjogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsXHJcbiAgICAgICAgICAgICAgICBkcm9wQ3NzID0gc2VsZi5kcm9wWm9uZUVuYWJsZWQgPyAnIGZpbGUtZHJvcC16b25lJyA6ICdmaWxlLWRyb3AtZGlzYWJsZWQnLFxyXG4gICAgICAgICAgICAgICAgY2xvc2UgPSAhc2VsZi5zaG93Q2xvc2UgPyAnJyA6IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdjbG9zZScpLFxyXG4gICAgICAgICAgICAgICAgcHJldmlldyA9ICFzZWxmLnNob3dQcmV2aWV3ID8gJycgOiBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgncHJldmlldycpXHJcbiAgICAgICAgICAgICAgICAgICAgLnNldFRva2Vucyh7J2NsYXNzJzogc2VsZi5wcmV2aWV3Q2xhc3MsICdkcm9wQ2xhc3MnOiBkcm9wQ3NzfSksXHJcbiAgICAgICAgICAgICAgICBjc3MgPSBzZWxmLmlzRGlzYWJsZWQgPyBzZWxmLmNhcHRpb25DbGFzcyArICcgZmlsZS1jYXB0aW9uLWRpc2FibGVkJyA6IHNlbGYuY2FwdGlvbkNsYXNzLFxyXG4gICAgICAgICAgICAgICAgY2FwdGlvbiA9IHNlbGYuY2FwdGlvblRlbXBsYXRlLnNldFRva2Vucyh7J2NsYXNzJzogY3NzICsgJyBrdi1maWxlaW5wdXQtY2FwdGlvbid9KTtcclxuICAgICAgICAgICAgcmV0dXJuIHNlbGYubWFpblRlbXBsYXRlLnNldFRva2Vucyh7XHJcbiAgICAgICAgICAgICAgICAnY2xhc3MnOiBzZWxmLm1haW5DbGFzcyArICghc2VsZi5zaG93QnJvd3NlICYmIHNlbGYuc2hvd0NhcHRpb24gPyAnIG5vLWJyb3dzZScgOiAnJyksXHJcbiAgICAgICAgICAgICAgICAncHJldmlldyc6IHByZXZpZXcsXHJcbiAgICAgICAgICAgICAgICAnY2xvc2UnOiBjbG9zZSxcclxuICAgICAgICAgICAgICAgICdjYXB0aW9uJzogY2FwdGlvbixcclxuICAgICAgICAgICAgICAgICd1cGxvYWQnOiBzZWxmLl9yZW5kZXJCdXR0b24oJ3VwbG9hZCcpLFxyXG4gICAgICAgICAgICAgICAgJ3JlbW92ZSc6IHNlbGYuX3JlbmRlckJ1dHRvbigncmVtb3ZlJyksXHJcbiAgICAgICAgICAgICAgICAnY2FuY2VsJzogc2VsZi5fcmVuZGVyQnV0dG9uKCdjYW5jZWwnKSxcclxuICAgICAgICAgICAgICAgICdicm93c2UnOiBzZWxmLl9yZW5kZXJCdXR0b24oJ2Jyb3dzZScpXHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICB9LFxyXG4gICAgICAgIF9yZW5kZXJCdXR0b246IGZ1bmN0aW9uICh0eXBlKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgdG1wbHQgPSBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgnYnRuRGVmYXVsdCcpLCBjc3MgPSBzZWxmW3R5cGUgKyAnQ2xhc3MnXSxcclxuICAgICAgICAgICAgICAgIHRpdGxlID0gc2VsZlt0eXBlICsgJ1RpdGxlJ10sIGljb24gPSBzZWxmW3R5cGUgKyAnSWNvbiddLCBsYWJlbCA9IHNlbGZbdHlwZSArICdMYWJlbCddLFxyXG4gICAgICAgICAgICAgICAgc3RhdHVzID0gc2VsZi5pc0Rpc2FibGVkID8gJyBkaXNhYmxlZCcgOiAnJywgYnRuVHlwZSA9ICdidXR0b24nO1xyXG4gICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgJ3JlbW92ZSc6XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dSZW1vdmUpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICcnO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2NhbmNlbCc6XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dDYW5jZWwpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICcnO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBjc3MgKz0gJyBrdi1oaWRkZW4nO1xyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSAndXBsb2FkJzpcclxuICAgICAgICAgICAgICAgICAgICBpZiAoIXNlbGYuc2hvd1VwbG9hZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJyc7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLmlzQWpheFVwbG9hZCAmJiAhc2VsZi5pc0Rpc2FibGVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHRtcGx0ID0gc2VsZi5fZ2V0TGF5b3V0VGVtcGxhdGUoJ2J0bkxpbmsnKS5yZXBsYWNlKCd7aHJlZn0nLCBzZWxmLnVwbG9hZFVybCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgYnRuVHlwZSA9ICdzdWJtaXQnO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAgICAgICAgIGNhc2UgJ2Jyb3dzZSc6XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzZWxmLnNob3dCcm93c2UpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICcnO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB0bXBsdCA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdidG5Ccm93c2UnKTtcclxuICAgICAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAg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hbHNlLCBmYWxzZSwgZmFsc2UpLFxyXG4gICAgICAgICAgICAgICAgICAgICdjYXB0aW9uJzogY2FwdGlvbixcclxuICAgICAgICAgICAgICAgICAgICAnc2l6ZSc6IHNpemUsXHJcbiAgICAgICAgICAgICAgICAgICAgJ3dpZHRoJzogd2lkdGgsXHJcbiAgICAgICAgICAgICAgICAgICAgJ3Byb2dyZXNzJzogc2VsZi5fcmVuZGVyVGh1bWJQcm9ncmVzcygpLFxyXG4gICAgICAgICAgICAgICAgICAgICdpbmRpY2F0b3InOiBpbmRpY2F0b3JcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgb3V0ID0gdGVtcGxhdGUuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAnYWN0aW9ucyc6IHNlbGYuX3JlbmRlckZpbGVBY3Rpb25zKGZhbHNlLCBmYWxzZSwgZmFsc2UsIHpvb20sIGRyZywgZmFsc2UsIGZhbHNlLCBmYWxzZSksXHJcbiAgICAgICAgICAgICAgICAgICAgJ2NhcHRpb24nOiBjYXB0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICdzaXplJzogc2l6ZSxcclxuICAgICAgICAgICAgICAgICAgICAnd2lkdGgnOiB3aWR0aCxcclxuICAgICAgICAgICAgICAgICAgICAncHJvZ3Jlc3MnOiAnJyxcclxuICAgICAgICAgICAgICAgICAgICAnaW5kaWNhdG9yJzogaW5kaWNhdG9yXHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBvdXQgPSAkaC5yZXBsYWNlVGFncyhvdXQsIHNlbGYucHJldmlld1RodW1iVGFncyk7XHJcbiAgICAgICAgICAgIHJldHVybiBvdXQ7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfcmVuZGVyRmlsZUFjdGlvbnM6IGZ1bmN0aW9uIChcclxuICAgICAgICAgICAgc2hvd1VwbCxcclxuICAgICAgICAgICAgc2hvd0R3bixcclxuICAgICAgICAgICAgc2hvd0RlbCxcclxuICAgICAgICAgICAgc2hvd1pvb20sXHJcbiAgICAgICAgICAgIHNob3dEcmFnLFxyXG4gICAgICAgICAgICBkaXNhYmxlZCxcclxuICAgICAgICAgICAgdXJsLFxyXG4gICAgICAgICAgICBrZXksXHJcbiAgICAgICAgICAgIGlzSW5pdCxcclxuICAgICAgICAgICAgZFVybCxcclxuICAgICAgICAgICAgZEZpbGVcclxuICAgICAgICApIHtcclxuICAgICAgICAgICAgaWYgKCFzaG93VXBsICYmICFzaG93RHduICYmICFzaG93RGVsICYmICFzaG93Wm9vbSAmJiAhc2hvd0RyYWcpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybiAnJztcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXMsIHZVcmwgPSB1cmwgPT09IGZhbHNlID8gJycgOiAnIGRhdGEtdXJsPVwiJyArIHVybCArICdcIicsXHJcbiAgICAgICAgICAgICAgICB2S2V5ID0ga2V5ID09PSBmYWxzZSA/ICcnIDogJyBkYXRhLWtleT1cIicgKyBrZXkgKyAnXCInLCBidG5EZWxldGUgPSAnJywgYnRuVXBsb2FkID0gJycsIGJ0bkRvd25sb2FkID0gJycsXHJcbiAgICAgICAgICAgICAgICBidG5ab29tID0gJycsIGJ0bkRyYWcgPSAnJywgY3NzLCB0ZW1wbGF0ZSA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdhY3Rpb25zJyksXHJcbiAgICAgICAgICAgICAgICBjb25maWcgPSBzZWxmLmZpbGVBY3Rpb25TZXR0aW5ncyxcclxuICAgICAgICAgICAgICAgIG90aGVyQnV0dG9ucyA9IHNlbGYub3RoZXJBY3Rpb25CdXR0b25zLnNldFRva2Vucyh7J2RhdGFLZXknOiB2S2V5LCAna2V5Jzoga2V5fSksXHJcbiAgICAgICAgICAgICAgICByZW1vdmVDbGFzcyA9IGRpc2FibGVkID8gY29uZmlnLnJlbW92ZUNsYXNzICsgJyBkaXNhYmxlZCcgOiBjb25maWcucmVtb3ZlQ2xhc3M7XHJcbiAgICAgICAgICAgIGlmIChzaG93RGVsKSB7XHJcbiAgICAgICAgICAgICAgICBidG5EZWxldGUgPSBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgnYWN0aW9uRGVsZXRlJykuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAncmVtb3ZlQ2xhc3MnOiByZW1vdmVDbGFzcyxcclxuICAgICAgICAgICAgICAgICAgICAncmVtb3ZlSWNvbic6IGNvbmZpZy5yZW1vdmVJY29uLFxyXG4gICAgICAgICAgICAgICAgICAgICdyZW1vdmVUaXRsZSc6IGNvbmZpZy5yZW1vdmVUaXRsZSxcclxuICAgICAgICAgICAgICAgICAgICAnZGF0YVVybCc6IHZVcmwsXHJcbiAgICAgICAgICAgICAgICAgICAgJ2RhdGFLZXknOiB2S2V5LFxyXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBrZXlcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzaG93VXBsKSB7XHJcbiAgICAgICAgICAgICAgICBidG5VcGxvYWQgPSBzZWxmLl9nZXRMYXlvdXRUZW1wbGF0ZSgnYWN0aW9uVXBsb2FkJykuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAndXBsb2FkQ2xhc3MnOiBjb25maWcudXBsb2FkQ2xhc3MsXHJcbiAgICAgICAgICAgICAgICAgICAgJ3VwbG9hZEljb24nOiBjb25maWcudXBsb2FkSWNvbixcclxuICAgICAgICAgICAgICAgICAgICAndXBsb2FkVGl0bGUnOiBjb25maWcudXBsb2FkVGl0bGVcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzaG93RHduKSB7XHJcbiAgICAgICAgICAgICAgICBidG5Eb3dubG9hZCA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdhY3Rpb25Eb3dubG9hZCcpLnNldFRva2Vucyh7XHJcbiAgICAgICAgICAgICAgICAgICAgJ2Rvd25sb2FkQ2xhc3MnOiBjb25maWcuZG93bmxvYWRDbGFzcyxcclxuICAgICAgICAgICAgICAgICAgICAnZG93bmxvYWRJY29uJzogY29uZmlnLmRvd25sb2FkSWNvbixcclxuICAgICAgICAgICAgICAgICAgICAnZG93bmxvYWRUaXRsZSc6IGNvbmZpZy5kb3dubG9hZFRpdGxlLFxyXG4gICAgICAgICAgICAgICAgICAgICdkb3dubG9hZFVybCc6IGRVcmwgfHwgc2VsZi5pbml0aWFsUHJldmlld0Rvd25sb2FkVXJsXHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIGJ0bkRvd25sb2FkID0gYnRuRG93bmxvYWQuc2V0VG9rZW5zKHsnZmlsZW5hbWUnOiBkRmlsZSwgJ2tleSc6IGtleX0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzaG93Wm9vbSkge1xyXG4gICAgICAgICAgICAgICAgYnRuWm9vbSA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdhY3Rpb25ab29tJykuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAnem9vbUNsYXNzJzogY29uZmlnLnpvb21DbGFzcyxcclxuICAgICAgICAgICAgICAgICAgICAnem9vbUljb24nOiBjb25maWcuem9vbUljb24sXHJcbiAgICAgICAgICAgICAgICAgICAgJ3pvb21UaXRsZSc6IGNvbmZpZy56b29tVGl0bGVcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzaG93RHJhZyAmJiBpc0luaXQpIHtcclxuICAgICAgICAgICAgICAgIGNzcyA9ICdkcmFnLWhhbmRsZS1pbml0ICcgKyBjb25maWcuZHJhZ0NsYXNzO1xyXG4gICAgICAgICAgICAgICAgYnRuRHJhZyA9IHNlbGYuX2dldExheW91dFRlbXBsYXRlKCdhY3Rpb25EcmFnJykuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAnZHJhZ0NsYXNzJzogY3NzLFxyXG4gICAgICAgICAgICAgICAgICAgICdkcmFnVGl0bGUnOiBjb25maWcuZHJhZ1RpdGxlLFxyXG4gICAgICAgICAgICAgICAgICAgICdkcmFnSWNvbic6IGNvbmZpZy5kcmFnSWNvblxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIHRlbXBsYXRlLnNldFRva2Vucyh7XHJcbiAgICAgICAgICAgICAgICAnZGVsZXRlJzogYnRuRGVsZXRlLFxyXG4gICAgICAgICAgICAgICAgJ3VwbG9hZCc6IGJ0blVwbG9hZCxcclxuICAgICAgICAgICAgICAgICdkb3dubG9hZCc6IGJ0bkRvd25sb2FkLFxyXG4gICAgICAgICAgICAgICAgJ3pvb20nOiBidG5ab29tLFxyXG4gICAgICAgICAgICAgICAgJ2RyYWcnOiBidG5EcmFnLFxyXG4gICAgICAgICAgICAgICAgJ290aGVyJzogb3RoZXJCdXR0b25zXHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2Jyb3dzZTogZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoZSAmJiBlLmlzRGVmYXVsdFByZXZlbnRlZCgpIHx8ICFzZWxmLl9yYWlzZSgnZmlsZWJyb3dzZScpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHNlbGYuaXNFcnJvciAmJiAhc2VsZi5pc0FqYXhVcGxvYWQpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuY2xlYXIoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyLmZvY3VzKCk7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfZmlsdGVyRHVwbGljYXRlOiBmdW5jdGlvbiAoZmlsZSwgZmlsZXMsIGZpbGVJZHMpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBmaWxlSWQgPSBzZWxmLl9nZXRGaWxlSWQoZmlsZSk7XHJcblxyXG4gICAgICAgICAgICBpZiAoZmlsZUlkICYmIGZpbGVJZHMgJiYgZmlsZUlkcy5pbmRleE9mKGZpbGVJZCkgPiAtMSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICghZmlsZUlkcykge1xyXG4gICAgICAgICAgICAgICAgZmlsZUlkcyA9IFtdO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGZpbGVzLnB1c2goZmlsZSk7XHJcbiAgICAgICAgICAgIGZpbGVJZHMucHVzaChmaWxlSWQpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgX2NoYW5nZTogZnVuY3Rpb24gKGUpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5jaGFuZ2VUcmlnZ2VyZWQpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB2YXIgJGVsID0gc2VsZi4kZWxlbWVudCwgaXNEcmFnRHJvcCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxLCBpc0FqYXhVcGxvYWQgPSBzZWxmLmlzQWpheFVwbG9hZCxcclxuICAgICAgICAgICAgICAgIHRmaWxlcyA9IFtdLCBmaWxlcyA9IGlzRHJhZ0Ryb3AgPyBhcmd1bWVudHNbMV0gOiAkZWwuZ2V0KDApLmZpbGVzLCB0b3RhbCxcclxuICAgICAgICAgICAgICAgIG1heENvdW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ICAgICAgIHNlbGYuaXNFcnJvciA9IHRocm93RXJyb3IobXNnLCBudWxsLCBudWxsLCBudWxsKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyLnJlbW92ZUNsYXNzKCdpY29uLXZpc2libGUnKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9zZXRDYXB0aW9uKCcnLCB0cnVlKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLiRjb250YWluZXIucmVtb3ZlQ2xhc3MoJ2ZpbGUtaW5wdXQtbmV3IGZpbGUtaW5wdXQtYWpheC1uZXcnKTtcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgIHNlbGYucmVhZGVyID0gbnVsbDtcclxuICAgICAgICAgICAgc2VsZi5fcmVzZXRVcGxvYWQoKTtcclxuICAgICAgICAgICAgc2VsZi5faGlkZUZpbGVJY29uKCk7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLmRyb3Bab25lRW5hYmxlZCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyLmZpbmQoJy5maWxlLWRyb3Atem9uZSAuJyArIHNlbGYuZHJvcFpvbmVUaXRsZUNsYXNzKS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoaXNBamF4VXBsb2FkKSB7XHJcbiAgICAgICAgICAgICAgICAkLmVhY2goZmlsZXMsIGZ1bmN0aW9uICh2S2V5LCB2RmlsZSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX2ZpbHRlckR1cGxpY2F0ZSh2RmlsZSwgdGZpbGVzLCBmaWxlSWRzKTtcclxuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgaWYgKGUudGFyZ2V0ICYmIGUudGFyZ2V0LmZpbGVzID09PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICBmaWxlcyA9IGUudGFyZ2V0LnZhbHVlID8gW3tuYW1lOiBlLnRhcmdldC52YWx1ZS5yZXBsYWNlKC9eLitcXFxcLywgJycpfV0gOiBbXTtcclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgZmlsZXMgPSBlLnRhcmdldC5maWxlcyB8fCB7fTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHRmaWxlcyA9IGZpbGVzO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmICgkaC5pc0VtcHR5KHRmaWxlcykgfHwgdGZpbGVzLmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFpc0FqYXhVcGxvYWQpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmNsZWFyKCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZXNlbGVjdG5vbmUnKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl9yZXNldEVycm9ycygpO1xyXG4gICAgICAgICAgICBsZW4gPSB0ZmlsZXMubGVuZ3RoO1xyXG4gICAgICAgICAgICB0b3RhbCA9IHNlbGYuX2dldEZpbGVDb3VudChpc0FqYXhVcGxvYWQgPyAoc2VsZi5nZXRGaWxlU3RhY2soKS5sZW5ndGggKyBsZW4pIDogbGVuKTtcclxuICAgICAgICAgICAgaWYgKG1heENvdW50ID4gMCAmJiB0b3RhbCA+IG1heENvdW50KSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoIXNlbGYuYXV0b1JlcGxhY2UgfHwgbGVuID4gbWF4Q291bnQpIHtcclxuICAgICAgICAgICAgICAgICAgICBtYXhDb3VudENoZWNrKChzZWxmLmF1dG9SZXBsYWNlICYmIGxlbiA+IG1heENvdW50ID8gbGVuIDogdG90YWwpLCBtYXhDb3VudCk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKHRvdGFsID4gbWF4Q291bnQpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9yZXNldFByZXZpZXdUaHVtYnMoaXNBamF4VXBsb2FkKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGlmICghaXNBamF4VXBsb2FkIHx8IGZsYWdTaW5nbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9yZXNldFByZXZpZXdUaHVtYnMoZmFsc2UpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChmbGFnU2luZ2xlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuY2xlYXJTdGFjaygpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQWpheFVwbG9hZCAmJiBjdHIgPT09IDAgJiYgKCFzZWxmLnByZXZpZXdDYWNoZS5jb3VudCgpIHx8IHNlbGYub3ZlcndyaXRlSW5pdGlhbCkpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmVzZXRQcmV2aWV3VGh1bWJzKHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoc2VsZi5pc1ByZXZpZXdhYmxlKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnJlYWRGaWxlcyh0ZmlsZXMpO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fdXBkYXRlRmlsZURldGFpbHMoMSk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9L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gW107XHJcbiAgICAgICAgICAgIHNlbGYuX2dldFRodW1icygpLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyksIGluZCA9ICR0aHVtYi5hdHRyKCdkYXRhLWZpbGVpbmRleCcpLCBmaWxlID0gc2VsZi5maWxlc3RhY2tbaW5kXSxcclxuICAgICAgICAgICAgICAgICAgICBwaWQgPSAkdGh1bWIuYXR0cignaWQnKTtcclxuICAgICAgICAgICAgICAgIGlmIChpbmQgPT09ICctMScgfHwgaW5kID09PSAtMSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaWxlICE9PSB1bmRlZmluZWQpIHtcclxuICAgICAgICAgICAgICAgICAgICBuZXdzdGFja1tpXSA9IGZpbGU7XHJcbiAgICAgICAgICAgICAgICAgICAgbmV3bmFtZXNbaV0gPSBzZWxmLl9nZXRGaWxlTmFtZShmaWxlKTtcclxuICAgICAgICAgICAgICAgICAgICBuZXdpZHNbaV0gPSBzZWxmLl9nZXRGaWxlSWQoZmlsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgJHRodW1iLmF0dHIoeydpZCc6IHNlbGYucHJldmlld0luaXRJZCArICctJyArIGksICdkYXRhLWZpbGVpbmRleCc6IGl9KTtcclxuICAgICAgICAgICAgICAgICAgICBpKys7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5hdHRyKHsnaWQnOiAndXBsb2FkZWQtJyArICRoLnVuaXFJZCgpLCAnZGF0YS1maWxlaW5kZXgnOiAnLTEnfSk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRwcmV2aWV3LmZpbmQoJyN6b29tLScgKyBwaWQpLmF0dHIoe1xyXG4gICAgICAgICAgICAgICAgICAgICdpZCc6ICd6b29tLScgKyAkdGh1bWIuYXR0cignaWQnKSxcclxuICAgICAgICAgICAgICAgICAgICAnZGF0YS1maWxlaW5kZXgnOiAkdGh1bWIuYXR0cignZGF0YS1maWxlaW5kZXgnKVxyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLmZpbGVzdGFjayA9IG5ld3N0YWNrO1xyXG4gICAgICAgICAgICBzZWxmLmZpbGVuYW1lcyA9IG5ld25hbWVzO1xyXG4gICAgICAgICAgICBzZWxmLmZpbGVpZHMgPSBuZXdpZHM7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBfaXNGaWxlU2VsZWN0aW9uVmFsaWQ6IGZ1bmN0aW9uIChjbnQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBjbnQgPSBjbnQgfHwgMDtcclxuICAgICAgICAgICAgaWYgKHNlbGYucmVxdWlyZWQgJiYgIXNlbGYuZ2V0RmlsZXNDb3VudCgpKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRlcnJvckNvbnRhaW5lci5odG1sKCcnKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Nob3dVcGxvYWRFcnJvcihzZWxmLm1zZ0ZpbGVSZXF1aXJlZCk7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHNlbGYubWluRmlsZUNvdW50ID4gMCAmJiBzZWxmLl9nZXRGaWxlQ291bnQoY250KSA8IHNlbGYubWluRmlsZUNvdW50KSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9ub0ZpbGVzRXJyb3Ioe30pO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY2xlYXJ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SWQsIHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLmlzQWpheFVwbG9hZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmFkZFRvU3RhY2sodW5kZWZpbmVkKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkRmlsZShpbmRleCArIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCAxMDApO1xyXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG51bUZpbGVzID0gMDtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdEZpbGVBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgJHRodW1iID0gJCgnIycgKyBwcmV2aWV3SWQpO1xyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKS5oaWRlKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGYucmVtb3ZlRnJvbVByZXZpZXdPbkVycm9yKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICR0aHVtYi5yZW1vdmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5pc0Vycm9yID0gc2VsZi5pc0FqYXhVcGxvYWQgPyBzZWxmLl9zaG93VXBsb2FkRXJyb3IobXNnLCBwMSkgOiBzZWxmLl9zaG93RXJyb3IobXNnLCBwMik7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fdXBkYXRlRmlsZURldGFpbHMobnVtRmlsZXMpO1xyXG4gICAgICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIHNlbGYubG9hZGVkSW1hZ2VzID0gW107XHJcbiAgICAgICAgICAgIHNlbGYudG90YWxJbWFnZXNDb3VudCA9IDA7XHJcblxyXG4gICAgICAgICAgICAkLmVhY2goZmlsZXMsIGZ1bmN0aW9uIChrZXksIGZpbGUpIHtcclxuICAgICAgICAgICAgICAgIHZhciBmdW5jID0gc2VsZi5maWxlVHlwZVNldHRpbmdzLmltYWdlO1xyXG4gICAgICAgICAgICAgICAgaWYgKGZ1bmMgJiYgZnVuYyhmaWxlLnR5cGUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi50b3RhbEltYWdlc0NvdW50Kys7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICByZWFkRmlsZSA9IGZ1bmN0aW9uIChpKSB7XHJcbiAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eSgkZWwuYXR0cignbXVsdGlwbGUnKSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBudW1GaWxlcyA9IDE7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoaSA+PSBudW1GaWxlcykge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLmlzQWpheFVwbG9hZCAmJiBzZWxmLmZpbGVzdGFjay5sZW5ndGggPiAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlYmF0Y2hzZWxlY3RlZCcsIFtzZWxmLmdldEZpbGVTdGFjaygpXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGViYXRjaHNlbGVjdGVkJywgW2ZpbGVzXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICRjb250YWluZXIucmVtb3ZlQ2xhc3MoJ2ZpbGUtdGh1bWItbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgICRzdGF0dXMuaHRtbCgnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdmFyIG5vZGUgPSBjdHIgKyBpLCBwcmV2aWV3SWQgPSBwcmV2aWV3SW5pdElkICsgJy0nICsgbm9kZSwgZmlsZSA9IGZpbGVzW2ldLCBmU2l6ZUtCLCBqLCBtc2csXHJcbiAgICAgICAgICAgICAgICAgICAgZm5UZXh0ID0gc2V0dGluZ3MudGV4dCwgZm5JbWFnZSA9IHNldHRpbmdzLmltYWdlLCBmbkh0bWwgPSBzZXR0aW5ncy5odG1sLCB0eXAsIGNoaywgdHlwMSwgdHlwMixcclxuICAgICAgICAgICAgICAgICAgICBjYXB0aW9uID0gc2VsZi5fZ2V0RmlsZU5hbWUoZmlsZSwgJycpLCBmaWxlU2l6ZSA9IChmaWxlICYmIGZpbGUuc2l6ZSB8fCAwKSAvIDEwMDAsXHJcbiAgICAgICAgICAgICAgICAgICAgZmlsZUV4dEV4cHIgPSAnJywgcHJldmlld0RhdGEgPSAkaC5jcmVhdGVPYmplY3RVUkwoZmlsZSksIGZpbGVDb3VudCA9IDAsXHJcbiAgICAgICAgICAgICAgICAgICAgc3RyVHlwZXMgPSAnJyxcclxuICAgICAgICAgICAgICAgICAgICBmdW5jLCBrbm93blR5cGVzID0gMCwgaXNUZXh0LCBpc0h0bWwsIGlzSW1hZ2UsIHR4dEZsYWcsIHByb2Nlc3NGaWxlTG9hZGVkID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgbXNnID0gbXNnUHJvZ3Jlc3Muc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdpbmRleCc6IGkgKyAxLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2ZpbGVzJzogbnVtRmlsZXMsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAncGVyY2VudCc6IDUwLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBjYXB0aW9uXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzdGF0dXMuaHRtbChtc2cpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fdXBkYXRlRmlsZURldGFpbHMobnVtRmlsZXMpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZEZpbGUoaSArIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCAxMDApO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWxvYWRlZCcsIFtmaWxlLCBwcmV2aWV3SWQsIGksIHJlYWRlcl0pO1xyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICBpZiAoIWZpbGUpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAodHlwTGVuID4gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB0eXBMZW47IGorKykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXAxID0gZmlsZVR5cGVzW2pdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXAyID0gc2VsZi5tc2dGaWxlVHlwZXNbdHlwMV0gfHwgdHlwMTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RyVHlwZXMgKz0gaiA9PT0gMCA/IHR5cDIgOiAnLCAnICsgdHlwMjtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoY2FwdGlvbiA9PT0gZmFsc2UpIHtcclxuICAgICAgICAgICAgICAgICAgICByZWFkRmlsZShpICsgMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKGNhcHRpb24ubGVuZ3RoID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gc2VsZi5tc2dJbnZhbGlkRmlsZU5hbWUucmVwbGFjZSgne25hbWV9JywgJGguaHRtbEVuY29kZSgkaC5nZXRGaWxlTmFtZShmaWxlKSwgJ1t1bmtub3duXScpKTtcclxuICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKG1zZywgZmlsZSwgcHJldmlld0lkLCBpKTtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBpZiAoISRoLmlzRW1wdHkoZmlsZUV4dCkpIHtcclxuICAgICAgICAgICAgICAgICAgICBmaWxlRXh0RXhwciA9IG5ldyBSZWdFeHAoJ1xcXFwuKCcgKyBmaWxlRXh0LmpvaW4oJ3wnKSArICcpJCcsICdpJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBmU2l6ZUtCID0gZmlsZVNpemUudG9GaXhlZCgyKTtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLm1heEZpbGVTaXplID4gMCAmJiBmaWxlU2l6ZSA+IHNlbGYubWF4RmlsZVNpemUpIHtcclxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBzZWxmLm1zZ1NpemVUb29MYXJnZS5zZXRUb2tlbnMoe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGNhcHRpb24sXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICdzaXplJzogZlNpemVLQixcclxuICAgICAgICAgICAgICAgICAgICAgICAgJ21heFNpemUnOiBzZWxmLm1heEZpbGVTaXplXHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcihtc2csIGZpbGUsIHByZXZpZXdJZCwgaSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKHNlbGYubWluRmlsZVNpemUgIT09IG51bGwgJiYgZmlsZVNpemUgPD0gJGguZ2V0TnVtKHNlbGYubWluRmlsZVNpemUpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gc2VsZi5tc2dTaXplVG9vU21hbGwuc2V0VG9rZW5zKHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBjYXB0aW9uLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAnc2l6ZSc6IGZTaXplS0IsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICdtaW5TaXplJzogc2VsZi5taW5GaWxlU2l6ZVxyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgICAgIHRocm93RXJyb3IobXNnLCBmaWxlLCBwcmV2aWV3SWQsIGkpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmICghJGguaXNFbXB0eShmaWxlVHlwZXMpICYmICRoLmlzQXJyYXkoZmlsZVR5cGVzKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBmaWxlVHlwZXMubGVuZ3RoOyBqICs9IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwID0gZmlsZVR5cGVzW2pdO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jID0gc2V0dGluZ3NbdHlwXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZmlsZUNvdW50ICs9ICFmdW5jIHx8ICh0eXBlb2YgZnVuYyAhPT0gJ2Z1bmN0aW9uJykgPyAwIDogKGZ1bmMoZmlsZS50eXBlLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJGguZ2V0RmlsZU5hbWUoZmlsZSkpID8gMSA6IDApO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAoZmlsZUNvdW50ID09PSAwKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIG1zZyA9IHNlbGYubXNnSW52YWxpZEZpbGVUeXBlLnNldFRva2Vucyh7J25hbWUnOiBjYXB0aW9uLCAndHlwZXMnOiBzdHJUeXBlc30pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKG1zZywgZmlsZSwgcHJldmlld0lkLCBpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChmaWxlQ291bnQgPT09IDAgJiYgISRoLmlzRW1wdHkoZmlsZUV4dCkgJiYgJGguaXNBcnJheShmaWxlRXh0KSAmJiAhJGguaXNFbXB0eShmaWxlRXh0RXhwcikpIHtcclxuICAgICAgICAgICAgICAgICAgICBjaGsgPSAkaC5jb21wYXJlKGNhcHRpb24sIGZpbGVFeHRFeHByKTtcclxuICAgICAgICAgICAgICAgICAgICBmaWxlQ291bnQgKz0gJGguaXNFbXB0eShjaGspID8gMCA6IGNoay5sZW5ndGg7XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGVDb3VudCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBtc2cgPSBzZWxmLm1zZ0ludmFsaWRGaWxlRXh0ZW5zaW9uLnNldFRva2Vucyh7J25hbWUnOiBjYXB0aW9uLCAnZXh0ZW5zaW9ucyc6IHN0ckV4dH0pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKG1zZywgZmlsZSwgcHJldmlld0lkLCBpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmICghc2VsZi5zaG93UHJldmlldykge1xyXG4gICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLmlzQWpheFVwbG9hZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmFkZFRvU3RhY2soZmlsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZWFkRmlsZShpICsgMSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX3VwZGF0ZUZpbGVEZXRhaWxzKG51bUZpbGVzKTtcclxuICAgICAgICAgICAgICAgICAgICB9LCAxMDApO1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlbG9hZGVkJywgW2ZpbGUsIHByZXZpZXdJZCwgaSwgcmVhZGVyXSk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgaWYgKCFjYW5QcmV2aWV3ICYmIGZpbGVTaXplID4gbWF4UHJldmlld1NpemUpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmFkZFRvU3RhY2soZmlsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgJGNvbnRhaW5lci5hZGRDbGFzcygnZmlsZS10aHVtYi1sb2FkaW5nJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcHJldmlld0RlZmF1bHQoZmlsZSwgcHJldmlld0lkKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0RmlsZUFjdGlvbnMoKTtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl91cGRhdGVGaWxlRGV0YWlscyhudW1GaWxlcyk7XHJcbiAgICAgICAgICAgICAgICAgICAgcmVhZEZpbGUoaSArIDEpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmICgkcHJldmlldy5sZW5ndGggJiYgRmlsZVJlYWRlciAhPT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgaXNUZXh0ID0gZm5UZXh0KGZpbGUudHlwZSwgY2FwdGlvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgaXNIdG1sID0gZm5IdG1sKGZpbGUudHlwZSwgY2FwdGlvbik7XHJcbiAgICAgICAgICAgICAgICAgICAgaXNJbWFnZSA9IGZuSW1hZ2UoZmlsZS50eXBlLCBjYXB0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAkc3RhdHVzLmh0bWwobXNnTG9hZGluZy5yZXBsYWNlKCd7aW5kZXh9JywgaSArIDEpLnJlcGxhY2UoJ3tmaWxlc30nLCBudW1GaWxlcykpO1xyXG4gICAgICAgICAgICAgICAgICAgICRjb250YWluZXIuYWRkQ2xhc3MoJ2ZpbGUtdGh1bWItbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgICAgIHJlYWRlci5vbmVycm9yID0gZnVuY3Rpb24gKGV2dCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9lcnJvckhhbmRsZXIoZXZ0LCBjYXB0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgIHJlYWRlci5vbmxvYWQgPSBmdW5jdGlvbiAodGhlRmlsZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaGV4LCBmaWxlSW5mbywgdWludCwgYnl0ZSwgYnl0ZXMgPSBbXSwgY29udGVudHMsIG1pbWUsIHJlYWRUZXh0SW1hZ2UgPSBmdW5jdGlvbiAodGV4dEZsYWcpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBuZXdSZWFkZXIgPSBuZXcgRmlsZVJlYWRlcigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3UmVhZGVyLm9uZXJyb3IgPSBmdW5jdGlvbiAodGhlRmlsZU5ldykge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuX2Vycm9ySGFuZGxlcih0aGVGaWxlTmV3LCBjYXB0aW9uKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSZWFkZXIub25sb2FkID0gZnVuY3Rpb24gKHRoZUZpbGVOZXcpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9wcmV2aWV3RmlsZShpLCBmaWxlLCB0aGVGaWxlTmV3LCBwcmV2aWV3SWQsIHByZXZpZXdEYXRhLCBmaWxlSW5mbyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5faW5pdEZpbGVBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc0ZpbGVMb2FkZWQoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dEZsYWcpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdSZWFkZXIucmVhZEFzVGV4dChmaWxlLCBzZWxmLnRleHRFbmNvZGluZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1JlYWRlci5yZWFkQXNEYXRhVVJMKGZpbGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlSW5mbyA9IHsnbmFtZSc6IGNhcHRpb24sICd0eXBlJzogZmlsZS50eXBlfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgJC5lYWNoKHNldHRpbmdzLCBmdW5jdGlvbiAoaywgZikge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGsgIT09ICdvYmplY3QnICYmIGsgIT09ICdvdGhlcicgJiYgdHlwZW9mIGYgPT09ICdmdW5jdGlvbicgJiYgZihmaWxlLnR5cGUsIGNhcHRpb24pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga25vd25UeXBlcysrO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtub3duVHlwZXMgPT09IDApIHsvLyBhdXRvIGRldGVjdCBtaW1lIHR5cGVzIGZyb20gY29udGVudCBpZiBubyBrbm93biBmaWxlIHR5cGVzIGRldGVjdGVkXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50ID0gbmV3IFVpbnQ4QXJyYXkodGhlRmlsZS50YXJnZXQucmVzdWx0KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB1aW50Lmxlbmd0aDsgaisrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZSA9IHVpbnRbal0udG9TdHJpbmcoMTYpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzLnB1c2goYnl0ZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZXggPSBieXRlcy5qb2luKCcnKS50b0xvd2VyQ2FzZSgpLnN1YnN0cmluZygwLCA4KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbWUgPSAkaC5nZXRNaW1lVHlwZShoZXgsICcnLCAnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoJGguaXNFbXB0eShtaW1lKSkgeyAvLyBsb29rIGZvciBhc2NpaSB0ZXh0IGNvbnRlbnRcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50cyA9ICRoLmFycmF5QnVmZmVyMlN0cmluZyhyZWFkZXIucmVzdWx0KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW1lID0gJGguaXNTdmcoY29udGVudHMpID8gJ2ltYWdlL3N2Zyt4bWwnIDogJGguZ2V0TWltZVR5cGUoaGV4LCBjb250ZW50cywgZmlsZS50eXBlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVJbmZvID0geyduYW1lJzogY2FwdGlvbiwgJ3R5cGUnOiBtaW1lfTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzVGV4dCA9IGZuVGV4dChtaW1lLCAnJyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0h0bWwgPSBmbkh0bWwobWltZSwgJycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNJbWFnZSA9IGZuSW1hZ2UobWltZSwgJycpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHh0RmxhZyA9IGlzVGV4dCB8fCBpc0h0bWw7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHh0RmxhZyB8fCBpc0ltYWdlKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZFRleHRJbWFnZSh0eHRGbGFnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fcHJldmlld0ZpbGUoaSwgZmlsZSwgdGhlRmlsZSwgcHJldmlld0lkLCBwcmV2aWV3RGF0YSwgZmlsZUluZm8pO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmLl9pbml0RmlsZUFjdGlvbnMoKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc0ZpbGVMb2FkZWQoKTtcclxuICAgICAgICAgICAgICAgICAgICB9O1xyXG4gICAgICAgICAgICAgICAgICAgIHJlYWRlci5vbnByb2dyZXNzID0gZnVuY3Rpb24gKGRhdGEpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoQ29tcHV0YWJsZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGZhY3QgPSAoZGF0YS5sb2FkZWQgLyBkYXRhLnRvdGFsKSAqIDEwMCwgcHJvZ3Jlc3MgPSBNYXRoLmNlaWwoZmFjdCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgPSBtc2dQcm9ncmVzcy5zZXRUb2tlbnMoe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICdpbmRleCc6IGkgKyAxLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICdmaWxlcyc6IG51bUZpbGVzLFxyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICdwZXJjZW50JzogcHJvZ3Jlc3MsXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBjYXB0aW9uXHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzdGF0dXMuaHRtbChtc2cpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgMTAwKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH07XHJcblxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1RleHQgfHwgaXNIdG1sKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5yZWFkQXNUZXh0KGZpbGUsIHNlbGYudGV4dEVuY29kaW5nKTtcclxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbWFnZSkge1xyXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWRBc0RhdGFVUkwoZmlsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIucmVhZEFzQXJyYXlCdWZmZXIoZmlsZSk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYuX3ByZXZpZXdEZWZhdWx0KGZpbGUsIHByZXZpZXdJZCk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRGaWxlKGkgKyAxKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fdXBkYXRlRmlsZURldGFpbHMobnVtRmlsZXMpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0sIDEwMCk7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGVsb2FkZWQnLCBbZmlsZSwgcHJldmlld0lkLCBpLCByZWFkZXJdKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYuYWRkVG9TdGFjayhmaWxlKTtcclxuICAgICAgICAgICAgfTtcclxuXHJcbiAgICAgICAgICAgIHJlYWRGaWxlKDApO1xyXG4gICAgICAgICAgICBzZWxmLl91cGRhdGVGaWxlRGV0YWlscyhudW1GaWxlcywgZmFsc2UpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgbG9jazogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIHNlbGYuX3Jlc2V0RXJyb3JzKCk7XHJcbiAgICAgICAgICAgIHNlbGYuZGlzYWJsZSgpO1xyXG4gICAgICAgICAgICBpZiAoc2VsZi5zaG93UmVtb3ZlKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRjb250YWluZXIuZmluZCgnLmZpbGVpbnB1dC1yZW1vdmUnKS5oaWRlKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKHNlbGYuc2hvd0NhbmNlbCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyLmZpbmQoJy5maWxlaW5wdXQtY2FuY2VsJykuc2hvdygpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlbG9jaycsIFtzZWxmLmZpbGVzdGFjaywgc2VsZi5fZ2V0RXh0cmFEYXRhKCldKTtcclxuICAgICAgICAgICAgcmV0dXJuIHNlbGYuJGVsZW1lbnQ7XHJcbiAgICAgICAgfSxcclxuICAgICAgICB1bmxvY2s6IGZ1bmN0aW9uIChyZXNldCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIGlmIChyZXNldCA9PT0gdW5kZWZpbmVkKSB7XHJcbiAgICAgICAgICAgICAgICByZXNldCA9IHRydWU7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5lbmFibGUoKTtcclxuICAgICAgICAgICAgaWYgKHNlbGYuc2hvd0NhbmNlbCkge1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY29udGFpbmVyLmZpbmQoJy5maWxlaW5wdXQtY2FuY2VsJykuaGlkZSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzZWxmLnNob3dSZW1vdmUpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuJGNvbnRhaW5lci5maW5kKCcuZmlsZWlucHV0LXJlbW92ZScpLnNob3coKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAocmVzZXQpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Jlc2V0RmlsZVN0YWNrKCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fcmFpc2UoJ2ZpbGV1bmxvY2snLCBbc2VsZi5maWxlc3RhY2ssIHNlbGYuX2dldEV4dHJhRGF0YSgpXSk7XHJcbiAgICAgICAgICAgIHJldHVybiBzZWxmLiRlbGVtZW50O1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgeGhyID0gc2VsZi5hamF4UmVxdWVzdHMsIGxlbiA9IHhoci5sZW5ndGgsIGk7XHJcbiAgICAgICAgICAgIGlmIChsZW4gPiAwKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpICs9IDEpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLmNhbmNlbGxpbmcgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgICAgIHhocltpXS5hYm9ydCgpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX3NldFByb2dyZXNzQ2FuY2VsbGVkKCk7XHJcbiAgICAgICAgICAgIHNlbGYuX2dldFRodW1icygpLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgdmFyICR0aHVtYiA9ICQodGhpcyksIGluZCA9ICR0aHVtYi5hdHRyKCdkYXRhLWZpbGVpbmRleCcpO1xyXG4gICAgICAgICAgICAgICAgJHRodW1iLnJlbW92ZUNsYXNzKCdmaWxlLXVwbG9hZGluZycpO1xyXG4gICAgICAgICAgICAgICAgaWYgKHNlbGYuZmlsZXN0YWNrW2luZF0gIT09IHVuZGVmaW5lZCkge1xyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5maW5kKCcua3YtZmlsZS11cGxvYWQnKS5yZW1vdmVDbGFzcygnZGlzYWJsZWQnKS5yZW1vdmVBdHRyKCdkaXNhYmxlZCcpO1xyXG4gICAgICAgICAgICAgICAgICAgICR0aHVtYi5maW5kKCcua3YtZmlsZS1yZW1vdmUnKS5yZW1vdmVDbGFzcygnZGlzYWJsZWQnKS5yZW1vdmVBdHRyKCdkaXNhYmxlZCcpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgc2VsZi51bmxvY2soKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIHJldHVybiBzZWxmLiRlbGVtZW50O1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgY2xlYXI6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCBjYXA7XHJcbiAgICAgICAgICAgIGlmICghc2VsZi5fcmFpc2UoJ2ZpbGVjbGVhcicpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi4kYnRuVXBsb2FkLnJlbW92ZUF0dHIoJ2Rpc2FibGVkJyk7XHJcbiAgICAgICAgICAgIHNlbGYuX2dldFRodW1icygpLmZpbmQoJ3ZpZGVvLGF1ZGlvLGltZycpLmVhY2goZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICAgICAgJGguY2xlYW5NZW1vcnkoJCh0aGlzKSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICBzZWxmLl9jbGVhckZpbGVJbnB1dCgpO1xyXG4gICAgICAgICAgICBzZWxmLl9yZXNldFVwbG9hZCgpO1xyXG4gICAgICAgICAgICBzZWxmLmNsZWFyU3RhY2soKTtcclxuICAgICAgICAgICAgc2VsZi5fcmVzZXRFcnJvcnModHJ1ZSk7XHJcbiAgICAgICAgICAgIGlmIChzZWxmLl9oYXNJbml0aWFsUHJldmlldygpKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9zaG93RmlsZUljb24oKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Jlc2V0UHJldmlldygpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFByZXZpZXdBY3Rpb25zKCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLiRjb250YWluZXIucmVtb3ZlQ2xhc3MoJ2ZpbGUtaW5wdXQtbmV3Jyk7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9nZXRUaHVtYnMoKS5lYWNoKGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLl9jbGVhck9iamVjdHMoJCh0aGlzKSk7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIGlmIChzZWxmLmlzQWpheFVwbG9hZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlbGYucHJldmlld0NhY2hlLmRhdGEgPSB7fTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYuJHByZXZpZXcuaHRtbCgnJyk7XHJcbiAgICAgICAgICAgICAgICBjYXAgPSAoIXNlbGYub3ZlcndyaXRlSW5pdGlhbCAmJiBzZWxmLmluaXRpYWxDYXB0aW9uLmxlbmd0aCA+IDApID8gc2VsZi5pbml0aWFsQ2FwdGlvbiA6ICcnO1xyXG4gICAgICAgICAgICAgICAgc2VsZi4kY2FwdGlvbi5hdHRyKCd0aXRsZScsICcnKS52YWwoY2FwKTtcclxuICAgICAgICAgICAgICAgICRoLmFkZENzcyhzZWxmLiRjb250YWluZXIsICdmaWxlLWlucHV0LW5ldycpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5fdmFsaWRhdGVEZWZhdWx0UHJldmlldygpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChzZWxmLiRjb250YWluZXIuZmluZCgkaC5GUkFNRVMpLmxlbmd0aCA9PT0gMCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFzZWxmLl9pbml0Q2FwdGlvbigpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi4kY2FwdGlvbkNvbnRhaW5lci5yZW1vdmVDbGFzcygnaWNvbi12aXNpYmxlJyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5faGlkZUZpbGVJY29uKCk7XHJcbiAgICAgICAgICAgIHNlbGYuX3JhaXNlKCdmaWxlY2xlYXJlZCcpO1xyXG4gICAgICAgICAgICBzZWxmLiRjYXB0aW9uQ29udGFpbmVyLmZvY3VzKCk7XHJcbiAgICAgICAgICAgIHNlbGYuX3NldEZpbGVEcm9wWm9uZVRpdGxlKCk7XHJcbiAgICAgICAgICAgIHJldHVybiBzZWxmLiRlbGVtZW50O1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgcmVzZXQ6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xyXG4gICAgICAgICAgICBpZiAoIXNlbGYuX3JhaXNlKCdmaWxlcmVzZXQnKSkge1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX3Jlc2V0UHJldmlldygpO1xyXG4gICAgICAgICAgICBzZWxmLiRjb250YWluZXIuZmluZCgnLmZpbGVpbnB1dC1maWxl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XMsIHRvdExlbiA9IHNlbGYuZ2V0RmlsZVN0YWNrKCkubGVuZ3RoLCBpLCBvdXREYXRhLCBsZW4sXHJcbiAgICAgICAgICAgICAgICBoYXNFeHRyYURhdGEgPSAhJC5pc0VtcHR5T2JqZWN0KHNlbGYuX2dldEV4dHJhRGF0YSgpKTtcclxuICAgICAgICAgICAgaWYgKCFzZWxmLmlzQWpheFVwbG9hZCB8fCBzZWxmLmlzRGlzYWJsZWQgfHwgIXNlbGYuX2lzRmlsZVNlbGVjdGlvblZhbGlkKHRvdExlbikpIHtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl9yZXNldFVwbG9hZCgpO1xyXG4gICAgICAgICAgICBpZiAodG90TGVuID09PSAwICYmICFoYXNFeHRyYURhdGEpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX3Nob3dVcGxvYWRFcnJvcihzZWxmLm1zZ1VwbG9hZEVtcHR5KTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLiRwcm9ncmVzcy5zaG93KCk7XHJcbiAgICAgICAgICAgIHNlbGYudXBsb2FkQ291bnQgPSAwO1xyXG4gICAgICAgICAgICBzZWxmLnVwbG9hZFN0YXR1cyA9IHt9O1xyXG4gICAgICAgICAgICBzZWxmLnVwbG9hZExvZyA9IFtdO1xyXG4gICAgICAgICAgICBzZWxmLmxvY2soKTtcclxuICAgICAgICAgICAgc2VsZi5fc2V0UHJvZ3Jlc3MoMik7XHJcbiAgICAgICAgICAgIGlmICh0b3RMZW4gPT09IDAgJiYgaGFzRXh0cmFEYXRhKSB7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl91cGxvYWRFeHRyYU9ubHkoKTtcclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBsZW4gPSBzZWxmLmZpbGVzdGFjay5sZW5ndGg7XHJcbiAgICAgICAgICAgIHNlbGYuaGFzSW5pdERhdGEgPSBmYWxzZTtcclxuICAgICAgICAgICAgaWYgKHNlbGYudXBsb2FkQXN5bmMpIHtcclxuICAgICAgICAgICAgICAgIG91dERhdGEgPSBzZWxmLl9nZXRPdXREYXRhKCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLl9yYWlzZSgnZmlsZWJhdGNocHJldXBsb2FkJywgW291dERhdGFdKTtcclxuICAgICAgICAgICAgICAgIHNlbGYuZmlsZUJhdGNoQ29tcGxldGVkID0gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICBzZWxmLnVwbG9hZENhY2hlID0ge2NvbnRlbnQ6IFtdLCBjb25maWc6IFtdLCB0YWdzOiBbXSwgYXBwZW5kOiB0cnVlfTtcclxuICAgICAgICAgICAgICAgIHNlbGYudXBsb2FkQXN5bmNDb3VudCA9IHNlbGYuZ2V0RmlsZVN0YWNrKCkubGVuZ3RoO1xyXG4gICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRDYWNoZS5jb250ZW50W2ldID0gbnVsbDtcclxuICAgICAgICAgICAgICAgICAgICBzZWxmLnVwbG9hZENhY2hlLmNvbmZpZ1tpXSA9IG51bGw7XHJcbiAgICAgICAgICAgICAgICAgICAgc2VsZi51cGxvYWRDYWNoZS50YWdzW2ldID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHNlbGYuJHByZXZpZXcuZmluZCgnLmZpbGUtcHJldmlldy1pbml0aWFsJykucmVtb3ZlQ2xhc3MoJGguU09SVF9DU1MpO1xyXG4gICAgICAgICAgICAgICAgc2VsZi5faW5pdFNvcnRhYmxlKCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmNhY2hlSW5pdGlhbFByZXZpZXcgPSBzZWxmLmdldFByZXZpZXcoKTtcclxuXHJcbiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5maWxlc3RhY2tbaV0pIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5fdXBsb2FkU2luZ2xlKGksIHRydWUpO1xyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBzZWxmLl91cGxvYWRCYXRjaCgpO1xyXG4gICAgICAgICAgICByZXR1cm4gc2VsZi4kZWxlbWVudDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIGRlc3Ryb3k6IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZm9ybSA9IHNlbGYuJGZvcm0sICRjb250ID0gc2VsZi4kY29udGFpbmVyLCAkZWwgPSBzZWxmLiRlbGVtZW50LCBucyA9IHNlbGYubmFtZXNwYWNlO1xyXG4gICAgICAgICAgICAkKGRvY3VtZW50KS5vZmYobnMpO1xyXG4gICAgICAgICAgICAkKHdpbmRvdykub2ZmKG5zKTtcclxuICAgICAgICAgICAgaWYgKCRmb3JtICYmICRmb3JtLmxlbmd0aCkge1xyXG4gICAgICAgICAgICAgICAgJGZvcm0ub2ZmKG5zKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoc2VsZi5pc0FqYXhVcGxvYWQpIHtcclxuICAgICAgICAgICAgICAgIHNlbGYuX2NsZWFyRmlsZUlucHV0KCk7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgc2VsZi5fY2xlYW51cCgpO1xyXG4gICAgICAgICAgICBzZWxmLl9pbml0UHJldmlld0NhY2hlKCk7XHJcbiAgICAgICAgICAgICRlbC5pbnNlcnRCZWZvcmUoJGNvbnQpLm9mZihucykucmVtb3ZlRGF0YSgpO1xyXG4gICAgICAgICAgICAkY29udC5vZmYoKS5yZW1vdmUoKTtcclxuICAgICAgICAgICAgcmV0dXJuICRlbDtcclxuICAgICAgICB9LFxyXG4gICAgICAgIHJlZnJlc2g6IGZ1bmN0aW9uIChvcHRpb25zKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcywgJGVsID0gc2VsZi4kZWxlbWVudDtcclxuICAgICAgICAgICAgaWYgKHR5cGVvZiBvcHRpb25zICE9PSAnb2JqZWN0JyB8fCAkaC5pc0VtcHR5KG9wdGlvbnMpKSB7XHJcbiAgICAgICAgICAgICAgICBvcHRpb25zID0gc2VsZi5vcHRpb25zO1xyXG4gICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgb3B0aW9ucyA9ICQuZXh0ZW5kKHRydWUsIHt9LCBzZWxmLm9wdGlvbnMsIG9wdGlvbnMpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXQob3B0aW9ucywgdHJ1ZSk7XHJcbiAgICAgICAgICAgIHNlbGYuX2xpc3RlbigpO1xyXG4gICAgICAgICAgICByZXR1cm4gJGVsO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgem9vbTogZnVuY3Rpb24gKGZyYW1lSWQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZnJhbWUgPSBzZWxmLl9nZXRGcmFtZShmcmFtZUlkKSwgJG1vZGFsID0gc2VsZi4kbW9kYWw7XHJcbiAgICAgICAgICAgIGlmICghJGZyYW1lKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgJGguaW5pdE1vZGFsKCRtb2RhbCk7XHJcbiAgICAgICAgICAgICRtb2RhbC5odG1sKHNlbGYuX2dldE1vZGFsQ29udGVudCgpKTtcclxuICAgICAgICAgICAgc2VsZi5fc2V0Wm9vbUNvbnRlbnQoJGZyYW1lKTtcclxuICAgICAgICAgICAgJG1vZGFsLm1vZGFsKCdzaG93Jyk7XHJcbiAgICAgICAgICAgIHNlbGYuX2luaXRab29tQnV0dG9ucygpO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgZ2V0RXhpZjogZnVuY3Rpb24gKGZyYW1lSWQpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZnJhbWUgPSBzZWxmLl9nZXRGcmFtZShmcmFtZUlkKTtcclxuICAgICAgICAgICAgcmV0dXJuICRmcmFtZSAmJiAkZnJhbWUuZGF0YSgnZXhpZicpIHx8IG51bGw7XHJcbiAgICAgICAgfSxcclxuICAgICAgICBnZXRGcmFtZXM6IGZ1bmN0aW9uIChjc3NGaWx0ZXIpIHtcclxuICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzLCAkZnJhbWVzO1xyXG4gICAgICAgICAgICBjc3NGaWx0ZXIgPSBjc3NGaWx0ZXIgfHwgJyc7XHJcbiAgICAgICAgICAgICRmcmFtZXMgPSBzZWxmLiRwcmV2aWV3LmZpbmQoJGguRlJBTUVTICsgY3NzRmlsdGVyKTtcclxuICAgICAgICAgICAgaWYgKHNlbGYucmV2ZXJzZVByZXZpZXdPcmRlcikge1xyXG4gICAgICAgICAgICAgICAgJGZyYW1lcyA9ICQoJGZyYW1lcy5nZXQoKS5yZXZlcnNlKCkpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiAkZnJhbWVzO1xyXG4gICAgICAgIH0sXHJcbiAgICAgICAgZ2V0UHJldmlldzogZnVuY3Rpb24gKCkge1xyXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XHJcbiAgICAgICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgICAgICBjb250ZW50OiBzZWxmLmluaXRpYWxQcmV2aWV3LFxyXG4gICAgICAgICAgICAgICAgY29uZmlnOiBzZWxmLmluaXRpYWxQcmV2aWV3Q29uZmlnLFxyXG4gICAgICAgICAgICAgICAgdGFnczogc2VsZi5pbml0aWFsUHJldmlld1RodW1iVGFnc1xyXG4gICAgICAgICAgICB9O1xyXG4gICAgICAgIH1cclxuICAgIH07XHJcblxyXG4gICAgJC5mbi5maWxlaW5wdXQgPSBmdW5jdGlvbiAob3B0aW9uKSB7XHJcbiAgICAgICAgaWYgKCEkaC5oYXNGaWxlQVBJU3VwcG9ydCgpICYmICEkaC5pc0lFKDkpKSB7XHJcbiAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICB9XHJcbiAgICAgICAgdmFyIGFyZ3MgPSBBcnJheS5hcHBseShudWxsLCBhcmd1bWVudHMpLCByZXR2YWxzID0gW107XHJcbiAgICAgICAgYXJncy5zaGlmdCgpO1xyXG4gICAgICAgIHRoaXMuZWFjaChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgIHZhciBzZWxmID0gJCh0aGlzKSwgZGF0YSA9IHNlbGYuZGF0YSgnZmlsZWlucHV0JyksIG9wdGlvbnMgPSB0eXBlb2Ygb3B0aW9uID09PSAnb2JqZWN0JyAmJiBvcHRpb24sXHJcbiAgICAgICAgICAgICAgICB0aGVtZSA9IG9wdGlvbnMudGhlbWUgfHwgc2VsZi5kYXRhKCd0aGVtZScpLCBsID0ge30sIHQgPSB7fSxcclxuICAgICAgICAgICAgICAgIGxhbmcgPSBvcHRpb25zLmxhbmd1YWdlIHx8IHNlbGYuZGF0YSgnbGFuZ3VhZ2UnKSB8fCAkLmZuLmZpbGVpbnB1dC5kZWZhdWx0cy5sYW5ndWFnZSB8fCAnZW4nLCBvcHQ7XHJcbiAgICAgICAgICAgIGlmICghZGF0YSkge1xyXG4gICAgICAgICAgICAgICAgaWYgKHRoZW1lKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgdCA9ICQuZm4uZmlsZWlucHV0VGhlbWVzW3RoZW1lXSB8fCB7fTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmIChsYW5nICE9PSAnZW4nICYmICEkaC5pc0VtcHR5KCQuZm4uZmlsZWlucHV0TG9jYWxlc1tsYW5nXSkpIHtcclxuICAgICAgICAgICAgICAgICAgICBsID0gJC5mbi5maWxlaW5wdXRMb2NhbGVzW2xhbmddIHx8IHt9O1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgb3B0ID0gJC5leHRlbmQodHJ1ZSwge30sICQuZm4uZmlsZWlucHV0LmRlZmF1bHRzLCB0LCAkLmZuLmZpbGVpbnB1dExvY2FsZXMuZW4sIGwsIG9wdGlvbnMsIHNlbGYuZGF0YSgpKTtcclxuICAgICAgICAgICAgICAgIGRhdGEgPSBuZXcgRmlsZUlucHV0KHRoaXMsIG9wdCk7XHJcbiAgICAgICAgICAgICAgICBzZWxmLmRhdGEoJ2ZpbGVpbnB1dCcsIGRhdGEpO1xyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAodHlwZW9mIG9wdGlvbiA9PT0gJ3N0cmluZycpIHtcclxuICAgICAgICAgICAgICAgIHJldHZhbHMucHVzaChkYXRhW29wdGlvbl0uYXBwbHkoZGF0YSwgYXJncykpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgc3dpdGNoIChyZXR2YWxzLmxlbmd0aCkge1xyXG4gICAgICAgICAgICBjYXNlIDA6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcztcclxuICAgICAgICAgICAgY2FzZSAxOlxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJldHZhbHNbMF07XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gcmV0dmFscztcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG5cclxuICAgICQuZm4uZmlsZWlucHV0LmRlZmF1bHRzID0ge1xyXG4gICAgICAgIGxhbmd1YWdlOiAnZW4nLFxyXG4gICAgICAgIHNob3dDYXB0aW9uOiB0cnVlLFxyXG4gICAgICAgIHNob3dC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