UNPKG

fy-kit

Version:

fy # 工具方法包

1,502 lines (1,232 loc) 1.76 MB
// this is banner (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-md5')) : typeof define === 'function' && define.amd ? define(['exports', 'js-md5'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['fy-kit'] = {}, global.md5$1)); }(this, (function (exports, md5$1) { 'use strict'; // this is a intro comment function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var md5__default = /*#__PURE__*/_interopDefaultLegacy(md5$1); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function getCjsExportFromNamespace (n) { return n && n['default'] || n; } var arrayLikeToArray = createCommonjsModule(function (module) { function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } module.exports = _arrayLikeToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(arrayLikeToArray); var arrayWithoutHoles = createCommonjsModule(function (module) { function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return arrayLikeToArray(arr); } module.exports = _arrayWithoutHoles; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(arrayWithoutHoles); var iterableToArray = createCommonjsModule(function (module) { function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } module.exports = _iterableToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(iterableToArray); var unsupportedIterableToArray = createCommonjsModule(function (module) { function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); } module.exports = _unsupportedIterableToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(unsupportedIterableToArray); var nonIterableSpread = createCommonjsModule(function (module) { function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } module.exports = _nonIterableSpread; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(nonIterableSpread); var toConsumableArray = createCommonjsModule(function (module) { function _toConsumableArray(arr) { return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); } module.exports = _toConsumableArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _toConsumableArray = unwrapExports(toConsumableArray); // call模拟 // Function.prototype.call_ = function (obj) { // //判断是否为null或者undefined,同时考虑传递参数不是对象情况 // obj = obj ? Object(obj) : window; // var args = []; // // 注意i从1开始 // for (var i = 1, len = arguments.length; i < len; i++) { // args.push("arguments[" + i + "]"); // }; // obj.fn = this; // 此时this就是函数fn // var result = eval("obj.fn(" + args + ")"); // 执行fn // delete obj.fn; //删除fn // return result; // }; // // apply模拟 // Function.prototype.apply_ = function (obj, arr) { // obj = obj ? Object(obj) : window; // obj.fn = this; // var result; // if (!arr) { // result = obj.fn(); // } else { // var args = []; // // 注意这里的i从0开始 // for (var i = 0, len = arr.length; i < len; i++) { // args.push("arr[" + i + "]"); // }; // result = eval("obj.fn(" + args + ")"); // 执行fn // }; // delete obj.fn; //删除fn // return result; // }; // ES6 call Function.prototype._call = function (obj) { var _obj; obj = obj || window; obj.fn = this; // 利用拓展运算符直接将arguments转为数组 var args = Array.prototype.slice.call(arguments).slice(1); var result = (_obj = obj).fn.apply(_obj, _toConsumableArray(args)); delete obj.fn; return result; }; // ES6 apply Function.prototype._apply = function (obj, arr) { obj = obj || window; obj.fn = this; var result; if (!arr) { result = obj.fn(); } else { var _obj2; result = (_obj2 = obj).fn.apply(_obj2, _toConsumableArray(arr)); } delete obj.fn; return result; }; //es6 bind Function.prototype._bind = function (context) { // 获取绑定时的传参 var args = Array.prototype.slice.call(arguments).slice(1), // 定义中转构造函数,用于通过原型连接绑定后的函数和调用bind的函数 F = function F() {}, // 记录调用函数,生成闭包,用于返回函数被调用时执行 self = this, // 定义返回(绑定)函数 bound = function bound() { // 合并参数,绑定时和调用时分别传入的 var finalArgs = [].concat(_toConsumableArray(args), Array.prototype.slice.call(arguments)); // 改变作用域,注:aplly/call是立即执行函数,即绑定会直接调用 // 这里之所以要使用instanceof做判断,是要区分是不是new xxx()调用的bind方法 return self.call.apply(self, [this instanceof F ? this : context].concat(_toConsumableArray(finalArgs))); }; // 将调用函数的原型赋值到中转函数的原型上 F.prototype = self.prototype; // 通过原型的方式继承调用函数的原型 bound.prototype = new F(); return bound; }; var _typeof_1 = createCommonjsModule(function (module) { function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { module.exports = _typeof = function _typeof(obj) { return typeof obj; }; module.exports["default"] = module.exports, module.exports.__esModule = true; } else { module.exports = _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; module.exports["default"] = module.exports, module.exports.__esModule = true; } return _typeof(obj); } module.exports = _typeof; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _typeof = unwrapExports(_typeof_1); var arr = []; var getProto = Object.getPrototypeOf; var slice = arr.slice; // Provide fallback for browsers without Array#flat. var flat = arr.flat ? function (array) { return arr.flat.call(array); } : function (array) { return arr.concat.apply([], array); }; var push = arr.push; var indexOf = arr.indexOf; // [[Class]] -> type pairs var class2type = {}; var toString = class2type.toString; var hasOwn = class2type.hasOwnProperty; var fnToString = hasOwn.toString; var ObjectFunctionString = fnToString.call(Object); // All support tests are defined in their respective modules. var support = {}; function isWindow(obj) { return obj != null && obj === obj.window; } var document$1 = window.document; var preservedScriptAttributes = { type: true, src: true, nonce: true, noModule: true }; function DOMEval(code, node, doc) { doc = doc || document$1; var i, val, script = doc.createElement("script"); script.text = code; if (node) { for (i in preservedScriptAttributes) { // Support: Firefox <=64 - 66+, 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 + ""; } return _typeof(obj) === "object" ? class2type[toString.call(obj)] || "object" : _typeof(obj); } var version = "@VERSION", rhtmlSuffix = /HTML$/i, // Define a local copy of jQuery jQuery = function jQuery(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); }; 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 toArray() { 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 get(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 pushStack(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 each(callback) { return jQuery.each(this, callback); }, map: function map(callback) { return this.pushStack(jQuery.map(this, function (elem, i) { return callback.call(elem, i, elem); })); }, slice: function slice$1() { return this.pushStack(slice.apply(this, arguments)); }, first: function first() { return this.eq(0); }, last: function last() { return this.eq(-1); }, even: function even() { return this.pushStack(jQuery.grep(this, function (_elem, i) { return (i + 1) % 2; })); }, odd: function odd() { return this.pushStack(jQuery.grep(this, function (_elem, i) { return i % 2; })); }, eq: function eq(i) { var len = this.length, j = +i + (i < 0 ? len : 0); return this.pushStack(j >= 0 && j < len ? [this[j]] : []); }, end: function end() { return this.prevObject || this.constructor(); } }; 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" && typeof target !== "function") { 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 error(msg) { throw new Error(msg); }, noop: function noop() {}, isPlainObject: function isPlainObject(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 isEmptyObject(obj) { var name; for (name in obj) { return false; } return true; }, // Evaluates a script in a provided context; falls back to the global one // if not specified. globalEval: function globalEval(code, options, doc) { DOMEval(code, { nonce: options && options.nonce }, doc); }, each: function each(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; }, // Retrieve the text value of an array of DOM nodes text: function text(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 += jQuery.text(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 += jQuery.text(elem); } } } else if (nodeType === 3 || nodeType === 4) { return elem.nodeValue; } // Do not include comment or processing instruction nodes return ret; }, // results is for internal usage only makeArray: function makeArray(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 inArray(elem, arr, i) { return arr == null ? -1 : indexOf.call(arr, elem, i); }, isXMLDoc: function isXMLDoc(elem) { var namespace = elem.namespaceURI, docElem = (elem.ownerDocument || elem).documentElement; // Assume HTML when documentElement doesn't yet exist, such as inside // document fragments. return !rhtmlSuffix.test(namespace || docElem && docElem.nodeName || "HTML"); }, merge: function merge(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 grep(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 map(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 flat(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) { var length = !!obj && obj.length, type = toType(obj); if (typeof obj === "function" || isWindow(obj)) { return false; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; } function nodeName(elem, name) { return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); } var documentElement = document$1.documentElement; var pop = arr.pop; // https://www.w3.org/TR/css3-selectors/#whitespace var whitespace = "[\\x20\\t\\r\\n\\f]"; var isIE = document$1.documentMode; var rbuggyQSA = [], testEl = document$1.createElement("div"), input = document$1.createElement("input"); // Support: IE 9 - 11+ // IE's :disabled selector does not pick up the children of disabled fieldsets if (isIE) { rbuggyQSA.push(":enabled", ":disabled"); } // Support: IE 11+, Edge 15 - 18+ // IE 11/Edge don't find elements on a `[name='']` query in some cases. // Adding a temporary attribute to the document before the selection works // around the issue. // Interestingly, IE 10 & older don't seem to have the issue. input.setAttribute("name", ""); testEl.appendChild(input); if (!testEl.querySelectorAll("[name='']").length) { rbuggyQSA.push("\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + "*(?:''|\"\")"); } rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|")); var rbuggyQSA$1 = rbuggyQSA; // IE/Edge don't support the :scope pseudo-class. try { document$1.querySelectorAll(":scope"); support.scope = true; } catch (e) {} jQuery.contains = function (a, b) { var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; return a === bup || !!(bup && bup.nodeType === 1 && ( // Support: IE 9 - 11+ // IE doesn't have `contains` on SVG. adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); }; // https://drafts.csswg.org/cssom/#common-serializing-idioms var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; function fcssescape(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; } jQuery.escapeSelector = function (sel) { return (sel + "").replace(rcssescape, fcssescape); }; var sort = arr.sort; var hasDuplicate; // Document order sorting function sortOrder(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 // Support: IE 11+, Edge 17 - 18+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing // two documents; shallow comparisons work. // eslint-disable-next-line eqeqeq compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : // Otherwise we know they are disconnected 1; // Disconnected nodes if (compare & 1) { // Choose the first element that is related to the document // Support: IE 11+, Edge 17 - 18+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing // two documents; shallow comparisons work. // eslint-disable-next-line eqeqeq if (a == document$1 || a.ownerDocument == document$1 && jQuery.contains(document$1, a)) { return -1; } // Support: IE 11+, Edge 17 - 18+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing // two documents; shallow comparisons work. // eslint-disable-next-line eqeqeq if (b == document$1 || b.ownerDocument == document$1 && jQuery.contains(document$1, b)) { return 1; } // Maintain original order return 0; } return compare & 4 ? -1 : 1; } /** * Document sorting and removing duplicates * @param {ArrayLike} results */ jQuery.uniqueSort = function (results) { var elem, duplicates = [], j = 0, i = 0; hasDuplicate = false; sort.call(results, sortOrder); if (hasDuplicate) { while (elem = results[i++]) { if (elem === results[i]) { j = duplicates.push(i); } } while (j--) { results.splice(duplicates[j], 1); } } return results; }; var preferredDoc = document$1, matches = documentElement.matches || documentElement.msMatchesSelector; (function () { var i, Expr, outermostContext, // Local document vars document, documentElement, documentIsHTML, // Instance-specific data expando = jQuery.expando, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" + "loop|multiple|open|readonly|required|scoped", // Regular expressions // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", // Attribute selectors: https://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") }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, // Easily-parseable/retrievable ID or TAG or CLASS selectors rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, // CSS escapes // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function funescape(escape, nonHex) { var high = "0x" + escape.slice(1) - 0x10000; if (nonHex) { // Strip the backslash prefix from a non-hex escape sequence return nonHex; } // Replace a hexadecimal escape sequence with the encoded Unicode code point // Support: IE <=11+ // For values outside the Basic Multilingual Plane (BMP), manually construct a // surrogate pair return high < 0 ? String.fromCharCode(high + 0x10000) : String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00); }, // Used for iframes; see `setDocument`. // Support: IE 9 - 11+, Edge 12 - 18+ // Removing the function wrapper causes a "Permission Denied" // error in IE/Edge. unloadHandler = function unloadHandler() { setDocument(); }, inDisabledFieldset = addCombinator(function (elem) { return elem.disabled === true && nodeName(elem, "fieldset"); }, { dir: "parentNode", next: "legend" }); function selectorError(msg) { throw new Error("Syntax error, unrecognized expression: " + msg); } function find(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) { 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)) { push.call(results, elem); } return results; // Element context } else { if (newContext && (elem = newContext.getElementById(m)) && jQuery.contains(context, elem)) { push.call(results, elem); return results; } } // Type selector } else if (match[2]) { push.apply(results, context.getElementsByTagName(selector)); return results; // Class selector } else if ((m = match[3]) && context.getElementsByClassName) { push.apply(results, context.getElementsByClassName(m)); return results; } } // Take advantage of querySelectorAll if (!nonnativeSelectorCache[selector + " "] && (!rbuggyQSA$1 || !rbuggyQSA$1.test(selector))) { 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. // The technique has to be used as well when a leading combinator is used // as such selectors are not recognized by querySelectorAll. // Thanks to Andrew Dupont for this technique. if (nodeType === 1 && (rdescend.test(selector) || rcombinators.test(selector))) { // Expand context for sibling selectors newContext = rsibling.test(selector) && testContext(context.parentNode) || context; // We can use :scope instead of the ID hack if the browser // supports it & if we're not changing the context. if (newContext !== context || !support.scope) { // Capture the context ID, setting it first if necessary if (nid = context.getAttribute("id")) { nid = jQuery.escapeSelector(nid); } else { context.setAttribute("id", nid = expando); } } // Prefix every selector in the list groups = tokenize(selector); i = groups.length; while (i--) { groups[i] = (nid ? "#" + nid : ":scope") + " " + toSelector(groups[i]); } newSelector = groups.join(","); } 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 jQuery selector module * @param {Function} fn The function to mark */ function markFunction(fn) { fn[expando] = true; return fn; } /** * Returns a function to use in pseudos for input types * @param {String} type */ function createInputPseudo(type) { return function (elem) { return nodeName(elem, "input") && elem.type === type; }; } /** * Returns a function to use in pseudos for buttons * @param {String} type */ function createButtonPseudo(type) { return function (elem) { return (nodeName(elem, "input") || nodeName(elem, "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 jQuery selector 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; } /** * Sets document-related variables once based on the current document * @param {Element|Object} [node] An element or document object to use to set the document */ function setDocument(node) { var subWindow, doc = node ? node.ownerDocument || node : preferredDoc; // Return early if doc is invalid or already selected // Support: IE 11+, Edge 17 - 18+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing // two documents; shallow comparisons work. // eslint-disable-next-line eqeqeq if (doc == document || doc.nodeType !== 9) { return; } // Update global variables document = doc; documentElement = document.documentElement; documentIsHTML = !jQuery.isXMLDoc(document); // Support: IE 9 - 11+, Edge 12 - 18+ // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) // Support: IE 11+, Edge 17 - 18+ // IE/Edge sometimes throw a "Permission denied" error when strict-comparing // two documents; shallow comparisons work. // eslint-disable-next-line eqeqeq if (preferredDoc != document && (subWindow = document.defaultView) && subWindow.top !== subWindow) { // Support: IE 9 - 11+, Edge 12 - 18+ subWindow.addEventListener("unload", unloadHandler); } } find.matches = function (expr, elements) { return find(expr, null, null, elements); }; find.matchesSelector = function (elem, expr) { setDocument(elem); if (documentIsHTML && !nonnativeSelectorCache[expr + " "] && (!rbuggyQSA$1 || !rbuggyQSA$1.test(expr))) { try { return matches.call(elem, expr); } catch (e) { nonnativeSelectorCache(expr, true); } } return find(expr, document, null, [elem]).length > 0; }; Expr = jQuery.expr = { // Can be adjusted by the user cacheLength: 50, createPseudo: markFunction, match: matchExpr, find: { ID: function ID(id, context) { if (typeof context.getElementById !== "undefined" && documentIsHTML) { var elem = context.getElementById(id); return elem ? [elem] : []; } }, TAG: function TAG(tag, context) { if (typeof context.getElementsByTagName !== "undefined") { return context.getElementsByTagName(tag); // DocumentFragment nodes don't have gEBTN } else { return context.querySelectorAll(tag); } }, CLASS: function CLASS(className, context) { if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) { return context.getElementsByClassName(className); } } }, relative: { ">": { dir: "parentNode", first: true }, " ": { dir: "parentNode" }, "+": { dir: "previousSibling", first: true }, "~": { dir: "previousSibling" } }, preFilter: { ATTR: function ATTR(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 CHILD(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]) { selectorError(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]) { selectorError(match[0]); } return match; }, PSEUDO: function PSEUDO(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: { ID: function ID(id) { var attrId = id.replace(runescape, funescape); return function (elem) { return elem.getAttribute("id") === attrId; }; }, TAG: function TAG(nodeNameSelector) { var expectedNodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase(); return nodeNameSelector === "*" ? function () { return true; } : function (elem) { return nodeName(elem, expectedNodeName); }; }, CLASS: function CLASS(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 ATTR(name, operator, check) { return function (elem) { var result = jQuery.attr(elem, name); if (result == null) { return operator === "!="; } if (!operator) { return true; } result += ""; if (operator === "=") { return result === check; } if (operator === "!=") { return result !== check; } if (operator === "^=") { return check && result.indexOf(check) === 0; } if (operator === "*=") { return check && result.indexOf(check) > -1; } if (operator === "$=") { return check && result.slice(-check.length) === check; } if (operator === "~=") { return (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1; } if (operator === "|=") { return result === check || result.slice(0, check.length + 1) === check + "-"; } return false; }; }, CHILD: function CHILD(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, 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 ? nodeName(node, 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 outerCache = parent[expando] || (parent[expando] = {}); cache = outerCache[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) { outerCache[type] = [dirruns, nodeIndex, diff]; break; } } } else { // Use previously-cached element index if available if (useCache) { outerCache = elem[expando] || (elem[expando] = {}); cache = outerCache[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 ? nodeName(node, name) : node.nodeType === 1) && ++diff) { // Cache the index of each encountered element if (useCache) { outerCache = node[expando] || (node[expando] = {}); outerCache[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(pseudo, argument) { // pseudo-class names are case-insensitive // https://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()] || selectorError("unsupported pseudo: " + pseudo); // The user may use createPseudo to indicate that // arguments are needed to create the filter function // just as jQuery 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.call(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, []),