qs.js 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493
  1. (function (f) {
  2. if (typeof exports === "object" && typeof module !== "undefined") {
  3. module.exports = f();
  4. } else if (typeof define === "function" && define.amd) {
  5. define([], f);
  6. } else {
  7. var g;
  8. if (typeof window !== "undefined") {
  9. g = window;
  10. } else if (typeof global !== "undefined") {
  11. g = global;
  12. } else if (typeof self !== "undefined") {
  13. g = self;
  14. } else {
  15. g = this;
  16. }
  17. g.Qs = f();
  18. }
  19. })(function () {
  20. var define, module, exports;
  21. return (function () {
  22. function r(e, n, t) {
  23. function o(i, f) {
  24. if (!n[i]) {
  25. if (!e[i]) {
  26. var c = "function" == typeof require && require;
  27. if (!f && c) return c(i, !0);
  28. if (u) return u(i, !0);
  29. var a = new Error("Cannot find module '" + i + "'");
  30. throw ((a.code = "MODULE_NOT_FOUND"), a);
  31. }
  32. var p = (n[i] = { exports: {} });
  33. e[i][0].call(
  34. p.exports,
  35. function (r) {
  36. var n = e[i][1][r];
  37. return o(n || r);
  38. },
  39. p,
  40. p.exports,
  41. r,
  42. e,
  43. n,
  44. t
  45. );
  46. }
  47. return n[i].exports;
  48. }
  49. for (
  50. var u = "function" == typeof require && require, i = 0;
  51. i < t.length;
  52. i++
  53. )
  54. o(t[i]);
  55. return o;
  56. }
  57. return r;
  58. })()(
  59. {
  60. 1: [
  61. function (require, module, exports) {
  62. "use strict";
  63. var replace = String.prototype.replace;
  64. var percentTwenties = /%20/g;
  65. var Format = {
  66. RFC1738: "RFC1738",
  67. RFC3986: "RFC3986",
  68. };
  69. module.exports = {
  70. default: Format.RFC3986,
  71. formatters: {
  72. RFC1738: function (value) {
  73. return replace.call(value, percentTwenties, "+");
  74. },
  75. RFC3986: function (value) {
  76. return String(value);
  77. },
  78. },
  79. RFC1738: Format.RFC1738,
  80. RFC3986: Format.RFC3986,
  81. };
  82. },
  83. {},
  84. ],
  85. 2: [
  86. function (require, module, exports) {
  87. "use strict";
  88. var stringify = require("./stringify");
  89. var parse = require("./parse");
  90. var formats = require("./formats");
  91. module.exports = {
  92. formats: formats,
  93. parse: parse,
  94. stringify: stringify,
  95. };
  96. },
  97. { "./formats": 1, "./parse": 3, "./stringify": 4 },
  98. ],
  99. 3: [
  100. function (require, module, exports) {
  101. "use strict";
  102. var utils = require("./utils");
  103. var has = Object.prototype.hasOwnProperty;
  104. var isArray = Array.isArray;
  105. var defaults = {
  106. allowDots: false,
  107. allowPrototypes: false,
  108. allowSparse: false,
  109. arrayLimit: 20,
  110. charset: "utf-8",
  111. charsetSentinel: false,
  112. comma: false,
  113. decoder: utils.decode,
  114. delimiter: "&",
  115. depth: 5,
  116. ignoreQueryPrefix: false,
  117. interpretNumericEntities: false,
  118. parameterLimit: 1000,
  119. parseArrays: true,
  120. plainObjects: false,
  121. strictNullHandling: false,
  122. };
  123. var interpretNumericEntities = function (str) {
  124. return str.replace(/&#(\d+);/g, function ($0, numberStr) {
  125. return String.fromCharCode(parseInt(numberStr, 10));
  126. });
  127. };
  128. var parseArrayValue = function (val, options) {
  129. if (
  130. val &&
  131. typeof val === "string" &&
  132. options.comma &&
  133. val.indexOf(",") > -1
  134. ) {
  135. return val.split(",");
  136. }
  137. return val;
  138. };
  139. // This is what browsers will submit when the ✓ character occurs in an
  140. // application/x-www-form-urlencoded body and the encoding of the page containing
  141. // the form is iso-8859-1, or when the submitted form has an accept-charset
  142. // attribute of iso-8859-1. Presumably also with other charsets that do not contain
  143. // the ✓ character, such as us-ascii.
  144. var isoSentinel = "utf8=%26%2310003%3B"; // encodeURIComponent('&#10003;')
  145. // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
  146. var charsetSentinel = "utf8=%E2%9C%93"; // encodeURIComponent('✓')
  147. var parseValues = function parseQueryStringValues(str, options) {
  148. var obj = {};
  149. var cleanStr = options.ignoreQueryPrefix
  150. ? str.replace(/^\?/, "")
  151. : str;
  152. var limit =
  153. options.parameterLimit === Infinity
  154. ? undefined
  155. : options.parameterLimit;
  156. var parts = cleanStr.split(options.delimiter, limit);
  157. var skipIndex = -1; // Keep track of where the utf8 sentinel was found
  158. var i;
  159. var charset = options.charset;
  160. if (options.charsetSentinel) {
  161. for (i = 0; i < parts.length; ++i) {
  162. if (parts[i].indexOf("utf8=") === 0) {
  163. if (parts[i] === charsetSentinel) {
  164. charset = "utf-8";
  165. } else if (parts[i] === isoSentinel) {
  166. charset = "iso-8859-1";
  167. }
  168. skipIndex = i;
  169. i = parts.length; // The eslint settings do not allow break;
  170. }
  171. }
  172. }
  173. for (i = 0; i < parts.length; ++i) {
  174. if (i === skipIndex) {
  175. continue;
  176. }
  177. var part = parts[i];
  178. var bracketEqualsPos = part.indexOf("]=");
  179. var pos =
  180. bracketEqualsPos === -1
  181. ? part.indexOf("=")
  182. : bracketEqualsPos + 1;
  183. var key, val;
  184. if (pos === -1) {
  185. key = options.decoder(part, defaults.decoder, charset, "key");
  186. val = options.strictNullHandling ? null : "";
  187. } else {
  188. key = options.decoder(
  189. part.slice(0, pos),
  190. defaults.decoder,
  191. charset,
  192. "key"
  193. );
  194. val = utils.maybeMap(
  195. parseArrayValue(part.slice(pos + 1), options),
  196. function (encodedVal) {
  197. return options.decoder(
  198. encodedVal,
  199. defaults.decoder,
  200. charset,
  201. "value"
  202. );
  203. }
  204. );
  205. }
  206. if (
  207. val &&
  208. options.interpretNumericEntities &&
  209. charset === "iso-8859-1"
  210. ) {
  211. val = interpretNumericEntities(val);
  212. }
  213. if (part.indexOf("[]=") > -1) {
  214. val = isArray(val) ? [val] : val;
  215. }
  216. if (has.call(obj, key)) {
  217. obj[key] = utils.combine(obj[key], val);
  218. } else {
  219. obj[key] = val;
  220. }
  221. }
  222. return obj;
  223. };
  224. var parseObject = function (chain, val, options, valuesParsed) {
  225. var leaf = valuesParsed ? val : parseArrayValue(val, options);
  226. for (var i = chain.length - 1; i >= 0; --i) {
  227. var obj;
  228. var root = chain[i];
  229. if (root === "[]" && options.parseArrays) {
  230. obj = [].concat(leaf);
  231. } else {
  232. obj = options.plainObjects ? Object.create(null) : {};
  233. var cleanRoot =
  234. root.charAt(0) === "[" && root.charAt(root.length - 1) === "]"
  235. ? root.slice(1, -1)
  236. : root;
  237. var index = parseInt(cleanRoot, 10);
  238. if (!options.parseArrays && cleanRoot === "") {
  239. obj = { 0: leaf };
  240. } else if (
  241. !isNaN(index) &&
  242. root !== cleanRoot &&
  243. String(index) === cleanRoot &&
  244. index >= 0 &&
  245. options.parseArrays &&
  246. index <= options.arrayLimit
  247. ) {
  248. obj = [];
  249. obj[index] = leaf;
  250. } else {
  251. obj[cleanRoot] = leaf;
  252. }
  253. }
  254. leaf = obj;
  255. }
  256. return leaf;
  257. };
  258. var parseKeys = function parseQueryStringKeys(
  259. givenKey,
  260. val,
  261. options,
  262. valuesParsed
  263. ) {
  264. if (!givenKey) {
  265. return;
  266. }
  267. // Transform dot notation to bracket notation
  268. var key = options.allowDots
  269. ? givenKey.replace(/\.([^.[]+)/g, "[$1]")
  270. : givenKey;
  271. // The regex chunks
  272. var brackets = /(\[[^[\]]*])/;
  273. var child = /(\[[^[\]]*])/g;
  274. // Get the parent
  275. var segment = options.depth > 0 && brackets.exec(key);
  276. var parent = segment ? key.slice(0, segment.index) : key;
  277. // Stash the parent if it exists
  278. var keys = [];
  279. if (parent) {
  280. // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
  281. if (!options.plainObjects && has.call(Object.prototype, parent)) {
  282. if (!options.allowPrototypes) {
  283. return;
  284. }
  285. }
  286. keys.push(parent);
  287. }
  288. // Loop through children appending to the array until we hit depth
  289. var i = 0;
  290. while (
  291. options.depth > 0 &&
  292. (segment = child.exec(key)) !== null &&
  293. i < options.depth
  294. ) {
  295. i += 1;
  296. if (
  297. !options.plainObjects &&
  298. has.call(Object.prototype, segment[1].slice(1, -1))
  299. ) {
  300. if (!options.allowPrototypes) {
  301. return;
  302. }
  303. }
  304. keys.push(segment[1]);
  305. }
  306. // If there's a remainder, just add whatever is left
  307. if (segment) {
  308. keys.push("[" + key.slice(segment.index) + "]");
  309. }
  310. return parseObject(keys, val, options, valuesParsed);
  311. };
  312. var normalizeParseOptions = function normalizeParseOptions(opts) {
  313. if (!opts) {
  314. return defaults;
  315. }
  316. if (
  317. opts.decoder !== null &&
  318. opts.decoder !== undefined &&
  319. typeof opts.decoder !== "function"
  320. ) {
  321. throw new TypeError("Decoder has to be a function.");
  322. }
  323. if (
  324. typeof opts.charset !== "undefined" &&
  325. opts.charset !== "utf-8" &&
  326. opts.charset !== "iso-8859-1"
  327. ) {
  328. throw new TypeError(
  329. "The charset option must be either utf-8, iso-8859-1, or undefined"
  330. );
  331. }
  332. var charset =
  333. typeof opts.charset === "undefined"
  334. ? defaults.charset
  335. : opts.charset;
  336. return {
  337. allowDots:
  338. typeof opts.allowDots === "undefined"
  339. ? defaults.allowDots
  340. : !!opts.allowDots,
  341. allowPrototypes:
  342. typeof opts.allowPrototypes === "boolean"
  343. ? opts.allowPrototypes
  344. : defaults.allowPrototypes,
  345. allowSparse:
  346. typeof opts.allowSparse === "boolean"
  347. ? opts.allowSparse
  348. : defaults.allowSparse,
  349. arrayLimit:
  350. typeof opts.arrayLimit === "number"
  351. ? opts.arrayLimit
  352. : defaults.arrayLimit,
  353. charset: charset,
  354. charsetSentinel:
  355. typeof opts.charsetSentinel === "boolean"
  356. ? opts.charsetSentinel
  357. : defaults.charsetSentinel,
  358. comma:
  359. typeof opts.comma === "boolean" ? opts.comma : defaults.comma,
  360. decoder:
  361. typeof opts.decoder === "function"
  362. ? opts.decoder
  363. : defaults.decoder,
  364. delimiter:
  365. typeof opts.delimiter === "string" ||
  366. utils.isRegExp(opts.delimiter)
  367. ? opts.delimiter
  368. : defaults.delimiter,
  369. // eslint-disable-next-line no-implicit-coercion, no-extra-parens
  370. depth:
  371. typeof opts.depth === "number" || opts.depth === false
  372. ? +opts.depth
  373. : defaults.depth,
  374. ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
  375. interpretNumericEntities:
  376. typeof opts.interpretNumericEntities === "boolean"
  377. ? opts.interpretNumericEntities
  378. : defaults.interpretNumericEntities,
  379. parameterLimit:
  380. typeof opts.parameterLimit === "number"
  381. ? opts.parameterLimit
  382. : defaults.parameterLimit,
  383. parseArrays: opts.parseArrays !== false,
  384. plainObjects:
  385. typeof opts.plainObjects === "boolean"
  386. ? opts.plainObjects
  387. : defaults.plainObjects,
  388. strictNullHandling:
  389. typeof opts.strictNullHandling === "boolean"
  390. ? opts.strictNullHandling
  391. : defaults.strictNullHandling,
  392. };
  393. };
  394. module.exports = function (str, opts) {
  395. var options = normalizeParseOptions(opts);
  396. if (str === "" || str === null || typeof str === "undefined") {
  397. return options.plainObjects ? Object.create(null) : {};
  398. }
  399. var tempObj =
  400. typeof str === "string" ? parseValues(str, options) : str;
  401. var obj = options.plainObjects ? Object.create(null) : {};
  402. // Iterate over the keys and setup the new object
  403. var keys = Object.keys(tempObj);
  404. for (var i = 0; i < keys.length; ++i) {
  405. var key = keys[i];
  406. var newObj = parseKeys(
  407. key,
  408. tempObj[key],
  409. options,
  410. typeof str === "string"
  411. );
  412. obj = utils.merge(obj, newObj, options);
  413. }
  414. if (options.allowSparse === true) {
  415. return obj;
  416. }
  417. return utils.compact(obj);
  418. };
  419. },
  420. { "./utils": 5 },
  421. ],
  422. 4: [
  423. function (require, module, exports) {
  424. "use strict";
  425. var getSideChannel = require("side-channel");
  426. var utils = require("./utils");
  427. var formats = require("./formats");
  428. var has = Object.prototype.hasOwnProperty;
  429. var arrayPrefixGenerators = {
  430. brackets: function brackets(prefix) {
  431. return prefix + "[]";
  432. },
  433. comma: "comma",
  434. indices: function indices(prefix, key) {
  435. return prefix + "[" + key + "]";
  436. },
  437. repeat: function repeat(prefix) {
  438. return prefix;
  439. },
  440. };
  441. var isArray = Array.isArray;
  442. var push = Array.prototype.push;
  443. var pushToArray = function (arr, valueOrArray) {
  444. push.apply(
  445. arr,
  446. isArray(valueOrArray) ? valueOrArray : [valueOrArray]
  447. );
  448. };
  449. var toISO = Date.prototype.toISOString;
  450. var defaultFormat = formats["default"];
  451. var defaults = {
  452. addQueryPrefix: false,
  453. allowDots: false,
  454. charset: "utf-8",
  455. charsetSentinel: false,
  456. delimiter: "&",
  457. encode: true,
  458. encoder: utils.encode,
  459. encodeValuesOnly: false,
  460. format: defaultFormat,
  461. formatter: formats.formatters[defaultFormat],
  462. // deprecated
  463. indices: false,
  464. serializeDate: function serializeDate(date) {
  465. return toISO.call(date);
  466. },
  467. skipNulls: false,
  468. strictNullHandling: false,
  469. };
  470. var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
  471. return (
  472. typeof v === "string" ||
  473. typeof v === "number" ||
  474. typeof v === "boolean" ||
  475. typeof v === "symbol" ||
  476. typeof v === "bigint"
  477. );
  478. };
  479. var stringify = function stringify(
  480. object,
  481. prefix,
  482. generateArrayPrefix,
  483. strictNullHandling,
  484. skipNulls,
  485. encoder,
  486. filter,
  487. sort,
  488. allowDots,
  489. serializeDate,
  490. format,
  491. formatter,
  492. encodeValuesOnly,
  493. charset,
  494. sideChannel
  495. ) {
  496. var obj = object;
  497. if (sideChannel.has(object)) {
  498. throw new RangeError("Cyclic object value");
  499. }
  500. if (typeof filter === "function") {
  501. obj = filter(prefix, obj);
  502. } else if (obj instanceof Date) {
  503. obj = serializeDate(obj);
  504. } else if (generateArrayPrefix === "comma" && isArray(obj)) {
  505. obj = utils.maybeMap(obj, function (value) {
  506. if (value instanceof Date) {
  507. return serializeDate(value);
  508. }
  509. return value;
  510. });
  511. }
  512. if (obj === null) {
  513. if (strictNullHandling) {
  514. return encoder && !encodeValuesOnly
  515. ? encoder(prefix, defaults.encoder, charset, "key", format)
  516. : prefix;
  517. }
  518. obj = "";
  519. }
  520. if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
  521. if (encoder) {
  522. var keyValue = encodeValuesOnly
  523. ? prefix
  524. : encoder(prefix, defaults.encoder, charset, "key", format);
  525. return [
  526. formatter(keyValue) +
  527. "=" +
  528. formatter(
  529. encoder(obj, defaults.encoder, charset, "value", format)
  530. ),
  531. ];
  532. }
  533. return [formatter(prefix) + "=" + formatter(String(obj))];
  534. }
  535. var values = [];
  536. if (typeof obj === "undefined") {
  537. return values;
  538. }
  539. var objKeys;
  540. if (generateArrayPrefix === "comma" && isArray(obj)) {
  541. // we need to join elements in
  542. objKeys = [
  543. { value: obj.length > 0 ? obj.join(",") || null : undefined },
  544. ];
  545. } else if (isArray(filter)) {
  546. objKeys = filter;
  547. } else {
  548. var keys = Object.keys(obj);
  549. objKeys = sort ? keys.sort(sort) : keys;
  550. }
  551. for (var i = 0; i < objKeys.length; ++i) {
  552. var key = objKeys[i];
  553. var value =
  554. typeof key === "object" && key.value !== undefined
  555. ? key.value
  556. : obj[key];
  557. if (skipNulls && value === null) {
  558. continue;
  559. }
  560. var keyPrefix = isArray(obj)
  561. ? typeof generateArrayPrefix === "function"
  562. ? generateArrayPrefix(prefix, key)
  563. : prefix
  564. : prefix + (allowDots ? "." + key : "[" + key + "]");
  565. sideChannel.set(object, true);
  566. pushToArray(
  567. values,
  568. stringify(
  569. value,
  570. keyPrefix,
  571. generateArrayPrefix,
  572. strictNullHandling,
  573. skipNulls,
  574. encoder,
  575. filter,
  576. sort,
  577. allowDots,
  578. serializeDate,
  579. format,
  580. formatter,
  581. encodeValuesOnly,
  582. charset,
  583. sideChannel
  584. )
  585. );
  586. }
  587. return values;
  588. };
  589. var normalizeStringifyOptions = function normalizeStringifyOptions(
  590. opts
  591. ) {
  592. if (!opts) {
  593. return defaults;
  594. }
  595. if (
  596. opts.encoder !== null &&
  597. opts.encoder !== undefined &&
  598. typeof opts.encoder !== "function"
  599. ) {
  600. throw new TypeError("Encoder has to be a function.");
  601. }
  602. var charset = opts.charset || defaults.charset;
  603. if (
  604. typeof opts.charset !== "undefined" &&
  605. opts.charset !== "utf-8" &&
  606. opts.charset !== "iso-8859-1"
  607. ) {
  608. throw new TypeError(
  609. "The charset option must be either utf-8, iso-8859-1, or undefined"
  610. );
  611. }
  612. var format = formats["default"];
  613. if (typeof opts.format !== "undefined") {
  614. if (!has.call(formats.formatters, opts.format)) {
  615. throw new TypeError("Unknown format option provided.");
  616. }
  617. format = opts.format;
  618. }
  619. var formatter = formats.formatters[format];
  620. var filter = defaults.filter;
  621. if (typeof opts.filter === "function" || isArray(opts.filter)) {
  622. filter = opts.filter;
  623. }
  624. return {
  625. addQueryPrefix:
  626. typeof opts.addQueryPrefix === "boolean"
  627. ? opts.addQueryPrefix
  628. : defaults.addQueryPrefix,
  629. allowDots:
  630. typeof opts.allowDots === "undefined"
  631. ? defaults.allowDots
  632. : !!opts.allowDots,
  633. charset: charset,
  634. charsetSentinel:
  635. typeof opts.charsetSentinel === "boolean"
  636. ? opts.charsetSentinel
  637. : defaults.charsetSentinel,
  638. delimiter:
  639. typeof opts.delimiter === "undefined"
  640. ? defaults.delimiter
  641. : opts.delimiter,
  642. encode:
  643. typeof opts.encode === "boolean"
  644. ? opts.encode
  645. : defaults.encode,
  646. encoder:
  647. typeof opts.encoder === "function"
  648. ? opts.encoder
  649. : defaults.encoder,
  650. encodeValuesOnly:
  651. typeof opts.encodeValuesOnly === "boolean"
  652. ? opts.encodeValuesOnly
  653. : defaults.encodeValuesOnly,
  654. filter: filter,
  655. format: format,
  656. formatter: formatter,
  657. serializeDate:
  658. typeof opts.serializeDate === "function"
  659. ? opts.serializeDate
  660. : defaults.serializeDate,
  661. skipNulls:
  662. typeof opts.skipNulls === "boolean"
  663. ? opts.skipNulls
  664. : defaults.skipNulls,
  665. sort: typeof opts.sort === "function" ? opts.sort : null,
  666. strictNullHandling:
  667. typeof opts.strictNullHandling === "boolean"
  668. ? opts.strictNullHandling
  669. : defaults.strictNullHandling,
  670. };
  671. };
  672. module.exports = function (object, opts) {
  673. var obj = object;
  674. var options = normalizeStringifyOptions(opts);
  675. var objKeys;
  676. var filter;
  677. if (typeof options.filter === "function") {
  678. filter = options.filter;
  679. obj = filter("", obj);
  680. } else if (isArray(options.filter)) {
  681. filter = options.filter;
  682. objKeys = filter;
  683. }
  684. var keys = [];
  685. if (typeof obj !== "object" || obj === null) {
  686. return "";
  687. }
  688. var arrayFormat;
  689. if (opts && opts.arrayFormat in arrayPrefixGenerators) {
  690. arrayFormat = opts.arrayFormat;
  691. } else if (opts && "indices" in opts) {
  692. arrayFormat = opts.indices ? "indices" : "repeat";
  693. } else {
  694. arrayFormat = "indices";
  695. }
  696. var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
  697. if (!objKeys) {
  698. objKeys = Object.keys(obj);
  699. }
  700. if (options.sort) {
  701. objKeys.sort(options.sort);
  702. }
  703. var sideChannel = getSideChannel();
  704. for (var i = 0; i < objKeys.length; ++i) {
  705. var key = objKeys[i];
  706. if (options.skipNulls && obj[key] === null) {
  707. continue;
  708. }
  709. pushToArray(
  710. keys,
  711. stringify(
  712. obj[key],
  713. key,
  714. generateArrayPrefix,
  715. options.strictNullHandling,
  716. options.skipNulls,
  717. options.encode ? options.encoder : null,
  718. options.filter,
  719. options.sort,
  720. options.allowDots,
  721. options.serializeDate,
  722. options.format,
  723. options.formatter,
  724. options.encodeValuesOnly,
  725. options.charset,
  726. sideChannel
  727. )
  728. );
  729. }
  730. var joined = keys.join(options.delimiter);
  731. var prefix = options.addQueryPrefix === true ? "?" : "";
  732. if (options.charsetSentinel) {
  733. if (options.charset === "iso-8859-1") {
  734. // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
  735. prefix += "utf8=%26%2310003%3B&";
  736. } else {
  737. // encodeURIComponent('✓')
  738. prefix += "utf8=%E2%9C%93&";
  739. }
  740. }
  741. return joined.length > 0 ? prefix + joined : "";
  742. };
  743. },
  744. { "./formats": 1, "./utils": 5, "side-channel": 16 },
  745. ],
  746. 5: [
  747. function (require, module, exports) {
  748. "use strict";
  749. var formats = require("./formats");
  750. var has = Object.prototype.hasOwnProperty;
  751. var isArray = Array.isArray;
  752. var hexTable = (function () {
  753. var array = [];
  754. for (var i = 0; i < 256; ++i) {
  755. array.push(
  756. "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase()
  757. );
  758. }
  759. return array;
  760. })();
  761. var compactQueue = function compactQueue(queue) {
  762. while (queue.length > 1) {
  763. var item = queue.pop();
  764. var obj = item.obj[item.prop];
  765. if (isArray(obj)) {
  766. var compacted = [];
  767. for (var j = 0; j < obj.length; ++j) {
  768. if (typeof obj[j] !== "undefined") {
  769. compacted.push(obj[j]);
  770. }
  771. }
  772. item.obj[item.prop] = compacted;
  773. }
  774. }
  775. };
  776. var arrayToObject = function arrayToObject(source, options) {
  777. var obj =
  778. options && options.plainObjects ? Object.create(null) : {};
  779. for (var i = 0; i < source.length; ++i) {
  780. if (typeof source[i] !== "undefined") {
  781. obj[i] = source[i];
  782. }
  783. }
  784. return obj;
  785. };
  786. var merge = function merge(target, source, options) {
  787. /* eslint no-param-reassign: 0 */
  788. if (!source) {
  789. return target;
  790. }
  791. if (typeof source !== "object") {
  792. if (isArray(target)) {
  793. target.push(source);
  794. } else if (target && typeof target === "object") {
  795. if (
  796. (options &&
  797. (options.plainObjects || options.allowPrototypes)) ||
  798. !has.call(Object.prototype, source)
  799. ) {
  800. target[source] = true;
  801. }
  802. } else {
  803. return [target, source];
  804. }
  805. return target;
  806. }
  807. if (!target || typeof target !== "object") {
  808. return [target].concat(source);
  809. }
  810. var mergeTarget = target;
  811. if (isArray(target) && !isArray(source)) {
  812. mergeTarget = arrayToObject(target, options);
  813. }
  814. if (isArray(target) && isArray(source)) {
  815. source.forEach(function (item, i) {
  816. if (has.call(target, i)) {
  817. var targetItem = target[i];
  818. if (
  819. targetItem &&
  820. typeof targetItem === "object" &&
  821. item &&
  822. typeof item === "object"
  823. ) {
  824. target[i] = merge(targetItem, item, options);
  825. } else {
  826. target.push(item);
  827. }
  828. } else {
  829. target[i] = item;
  830. }
  831. });
  832. return target;
  833. }
  834. return Object.keys(source).reduce(function (acc, key) {
  835. var value = source[key];
  836. if (has.call(acc, key)) {
  837. acc[key] = merge(acc[key], value, options);
  838. } else {
  839. acc[key] = value;
  840. }
  841. return acc;
  842. }, mergeTarget);
  843. };
  844. var assign = function assignSingleSource(target, source) {
  845. return Object.keys(source).reduce(function (acc, key) {
  846. acc[key] = source[key];
  847. return acc;
  848. }, target);
  849. };
  850. var decode = function (str, decoder, charset) {
  851. var strWithoutPlus = str.replace(/\+/g, " ");
  852. if (charset === "iso-8859-1") {
  853. // unescape never throws, no try...catch needed:
  854. return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
  855. }
  856. // utf-8
  857. try {
  858. return decodeURIComponent(strWithoutPlus);
  859. } catch (e) {
  860. return strWithoutPlus;
  861. }
  862. };
  863. var encode = function encode(
  864. str,
  865. defaultEncoder,
  866. charset,
  867. kind,
  868. format
  869. ) {
  870. // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
  871. // It has been adapted here for stricter adherence to RFC 3986
  872. if (str.length === 0) {
  873. return str;
  874. }
  875. var string = str;
  876. if (typeof str === "symbol") {
  877. string = Symbol.prototype.toString.call(str);
  878. } else if (typeof str !== "string") {
  879. string = String(str);
  880. }
  881. if (charset === "iso-8859-1") {
  882. return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
  883. return "%26%23" + parseInt($0.slice(2), 16) + "%3B";
  884. });
  885. }
  886. var out = "";
  887. for (var i = 0; i < string.length; ++i) {
  888. var c = string.charCodeAt(i);
  889. if (
  890. c === 0x2d || // -
  891. c === 0x2e || // .
  892. c === 0x5f || // _
  893. c === 0x7e || // ~
  894. (c >= 0x30 && c <= 0x39) || // 0-9
  895. (c >= 0x41 && c <= 0x5a) || // a-z
  896. (c >= 0x61 && c <= 0x7a) || // A-Z
  897. (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
  898. ) {
  899. out += string.charAt(i);
  900. continue;
  901. }
  902. if (c < 0x80) {
  903. out = out + hexTable[c];
  904. continue;
  905. }
  906. if (c < 0x800) {
  907. out =
  908. out +
  909. (hexTable[0xc0 | (c >> 6)] + hexTable[0x80 | (c & 0x3f)]);
  910. continue;
  911. }
  912. if (c < 0xd800 || c >= 0xe000) {
  913. out =
  914. out +
  915. (hexTable[0xe0 | (c >> 12)] +
  916. hexTable[0x80 | ((c >> 6) & 0x3f)] +
  917. hexTable[0x80 | (c & 0x3f)]);
  918. continue;
  919. }
  920. i += 1;
  921. c =
  922. 0x10000 +
  923. (((c & 0x3ff) << 10) | (string.charCodeAt(i) & 0x3ff));
  924. out +=
  925. hexTable[0xf0 | (c >> 18)] +
  926. hexTable[0x80 | ((c >> 12) & 0x3f)] +
  927. hexTable[0x80 | ((c >> 6) & 0x3f)] +
  928. hexTable[0x80 | (c & 0x3f)];
  929. }
  930. return out;
  931. };
  932. var compact = function compact(value) {
  933. var queue = [{ obj: { o: value }, prop: "o" }];
  934. var refs = [];
  935. for (var i = 0; i < queue.length; ++i) {
  936. var item = queue[i];
  937. var obj = item.obj[item.prop];
  938. var keys = Object.keys(obj);
  939. for (var j = 0; j < keys.length; ++j) {
  940. var key = keys[j];
  941. var val = obj[key];
  942. if (
  943. typeof val === "object" &&
  944. val !== null &&
  945. refs.indexOf(val) === -1
  946. ) {
  947. queue.push({ obj: obj, prop: key });
  948. refs.push(val);
  949. }
  950. }
  951. }
  952. compactQueue(queue);
  953. return value;
  954. };
  955. var isRegExp = function isRegExp(obj) {
  956. return Object.prototype.toString.call(obj) === "[object RegExp]";
  957. };
  958. var isBuffer = function isBuffer(obj) {
  959. if (!obj || typeof obj !== "object") {
  960. return false;
  961. }
  962. return !!(
  963. obj.constructor &&
  964. obj.constructor.isBuffer &&
  965. obj.constructor.isBuffer(obj)
  966. );
  967. };
  968. var combine = function combine(a, b) {
  969. return [].concat(a, b);
  970. };
  971. var maybeMap = function maybeMap(val, fn) {
  972. if (isArray(val)) {
  973. var mapped = [];
  974. for (var i = 0; i < val.length; i += 1) {
  975. mapped.push(fn(val[i]));
  976. }
  977. return mapped;
  978. }
  979. return fn(val);
  980. };
  981. module.exports = {
  982. arrayToObject: arrayToObject,
  983. assign: assign,
  984. combine: combine,
  985. compact: compact,
  986. decode: decode,
  987. encode: encode,
  988. isBuffer: isBuffer,
  989. isRegExp: isRegExp,
  990. maybeMap: maybeMap,
  991. merge: merge,
  992. };
  993. },
  994. { "./formats": 1 },
  995. ],
  996. 6: [function (require, module, exports) {}, {}],
  997. 7: [
  998. function (require, module, exports) {
  999. "use strict";
  1000. var GetIntrinsic = require("get-intrinsic");
  1001. var callBind = require("./");
  1002. var $indexOf = callBind(GetIntrinsic("String.prototype.indexOf"));
  1003. module.exports = function callBoundIntrinsic(name, allowMissing) {
  1004. var intrinsic = GetIntrinsic(name, !!allowMissing);
  1005. if (
  1006. typeof intrinsic === "function" &&
  1007. $indexOf(name, ".prototype.") > -1
  1008. ) {
  1009. return callBind(intrinsic);
  1010. }
  1011. return intrinsic;
  1012. };
  1013. },
  1014. { "./": 8, "get-intrinsic": 11 },
  1015. ],
  1016. 8: [
  1017. function (require, module, exports) {
  1018. "use strict";
  1019. var bind = require("function-bind");
  1020. var GetIntrinsic = require("get-intrinsic");
  1021. var $apply = GetIntrinsic("%Function.prototype.apply%");
  1022. var $call = GetIntrinsic("%Function.prototype.call%");
  1023. var $reflectApply =
  1024. GetIntrinsic("%Reflect.apply%", true) || bind.call($call, $apply);
  1025. var $gOPD = GetIntrinsic("%Object.getOwnPropertyDescriptor%", true);
  1026. var $defineProperty = GetIntrinsic("%Object.defineProperty%", true);
  1027. var $max = GetIntrinsic("%Math.max%");
  1028. if ($defineProperty) {
  1029. try {
  1030. $defineProperty({}, "a", { value: 1 });
  1031. } catch (e) {
  1032. // IE 8 has a broken defineProperty
  1033. $defineProperty = null;
  1034. }
  1035. }
  1036. module.exports = function callBind(originalFunction) {
  1037. var func = $reflectApply(bind, $call, arguments);
  1038. if ($gOPD && $defineProperty) {
  1039. var desc = $gOPD(func, "length");
  1040. if (desc.configurable) {
  1041. // original length, plus the receiver, minus any additional arguments (after the receiver)
  1042. $defineProperty(func, "length", {
  1043. value:
  1044. 1 +
  1045. $max(0, originalFunction.length - (arguments.length - 1)),
  1046. });
  1047. }
  1048. }
  1049. return func;
  1050. };
  1051. var applyBind = function applyBind() {
  1052. return $reflectApply(bind, $apply, arguments);
  1053. };
  1054. if ($defineProperty) {
  1055. $defineProperty(module.exports, "apply", { value: applyBind });
  1056. } else {
  1057. module.exports.apply = applyBind;
  1058. }
  1059. },
  1060. { "function-bind": 10, "get-intrinsic": 11 },
  1061. ],
  1062. 9: [
  1063. function (require, module, exports) {
  1064. "use strict";
  1065. /* eslint no-invalid-this: 1 */
  1066. var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
  1067. var slice = Array.prototype.slice;
  1068. var toStr = Object.prototype.toString;
  1069. var funcType = "[object Function]";
  1070. module.exports = function bind(that) {
  1071. var target = this;
  1072. if (
  1073. typeof target !== "function" ||
  1074. toStr.call(target) !== funcType
  1075. ) {
  1076. throw new TypeError(ERROR_MESSAGE + target);
  1077. }
  1078. var args = slice.call(arguments, 1);
  1079. var bound;
  1080. var binder = function () {
  1081. if (this instanceof bound) {
  1082. var result = target.apply(
  1083. this,
  1084. args.concat(slice.call(arguments))
  1085. );
  1086. if (Object(result) === result) {
  1087. return result;
  1088. }
  1089. return this;
  1090. } else {
  1091. return target.apply(that, args.concat(slice.call(arguments)));
  1092. }
  1093. };
  1094. var boundLength = Math.max(0, target.length - args.length);
  1095. var boundArgs = [];
  1096. for (var i = 0; i < boundLength; i++) {
  1097. boundArgs.push("$" + i);
  1098. }
  1099. bound = Function(
  1100. "binder",
  1101. "return function (" +
  1102. boundArgs.join(",") +
  1103. "){ return binder.apply(this,arguments); }"
  1104. )(binder);
  1105. if (target.prototype) {
  1106. var Empty = function Empty() {};
  1107. Empty.prototype = target.prototype;
  1108. bound.prototype = new Empty();
  1109. Empty.prototype = null;
  1110. }
  1111. return bound;
  1112. };
  1113. },
  1114. {},
  1115. ],
  1116. 10: [
  1117. function (require, module, exports) {
  1118. "use strict";
  1119. var implementation = require("./implementation");
  1120. module.exports = Function.prototype.bind || implementation;
  1121. },
  1122. { "./implementation": 9 },
  1123. ],
  1124. 11: [
  1125. function (require, module, exports) {
  1126. "use strict";
  1127. var undefined;
  1128. var $SyntaxError = SyntaxError;
  1129. var $Function = Function;
  1130. var $TypeError = TypeError;
  1131. // eslint-disable-next-line consistent-return
  1132. var getEvalledConstructor = function (expressionSyntax) {
  1133. try {
  1134. return $Function(
  1135. '"use strict"; return (' + expressionSyntax + ").constructor;"
  1136. )();
  1137. } catch (e) {}
  1138. };
  1139. var $gOPD = Object.getOwnPropertyDescriptor;
  1140. if ($gOPD) {
  1141. try {
  1142. $gOPD({}, "");
  1143. } catch (e) {
  1144. $gOPD = null; // this is IE 8, which has a broken gOPD
  1145. }
  1146. }
  1147. var throwTypeError = function () {
  1148. throw new $TypeError();
  1149. };
  1150. var ThrowTypeError = $gOPD
  1151. ? (function () {
  1152. try {
  1153. // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
  1154. arguments.callee; // IE 8 does not throw here
  1155. return throwTypeError;
  1156. } catch (calleeThrows) {
  1157. try {
  1158. // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
  1159. return $gOPD(arguments, "callee").get;
  1160. } catch (gOPDthrows) {
  1161. return throwTypeError;
  1162. }
  1163. }
  1164. })()
  1165. : throwTypeError;
  1166. var hasSymbols = require("has-symbols")();
  1167. var getProto =
  1168. Object.getPrototypeOf ||
  1169. function (x) {
  1170. return x.__proto__;
  1171. }; // eslint-disable-line no-proto
  1172. var needsEval = {};
  1173. var TypedArray =
  1174. typeof Uint8Array === "undefined"
  1175. ? undefined
  1176. : getProto(Uint8Array);
  1177. var INTRINSICS = {
  1178. "%AggregateError%":
  1179. typeof AggregateError === "undefined"
  1180. ? undefined
  1181. : AggregateError,
  1182. "%Array%": Array,
  1183. "%ArrayBuffer%":
  1184. typeof ArrayBuffer === "undefined" ? undefined : ArrayBuffer,
  1185. "%ArrayIteratorPrototype%": hasSymbols
  1186. ? getProto([][Symbol.iterator]())
  1187. : undefined,
  1188. "%AsyncFromSyncIteratorPrototype%": undefined,
  1189. "%AsyncFunction%": needsEval,
  1190. "%AsyncGenerator%": needsEval,
  1191. "%AsyncGeneratorFunction%": needsEval,
  1192. "%AsyncIteratorPrototype%": needsEval,
  1193. "%Atomics%": typeof Atomics === "undefined" ? undefined : Atomics,
  1194. "%BigInt%": typeof BigInt === "undefined" ? undefined : BigInt,
  1195. "%Boolean%": Boolean,
  1196. "%DataView%":
  1197. typeof DataView === "undefined" ? undefined : DataView,
  1198. "%Date%": Date,
  1199. "%decodeURI%": decodeURI,
  1200. "%decodeURIComponent%": decodeURIComponent,
  1201. "%encodeURI%": encodeURI,
  1202. "%encodeURIComponent%": encodeURIComponent,
  1203. "%Error%": Error,
  1204. "%eval%": eval, // eslint-disable-line no-eval
  1205. "%EvalError%": EvalError,
  1206. "%Float32Array%":
  1207. typeof Float32Array === "undefined" ? undefined : Float32Array,
  1208. "%Float64Array%":
  1209. typeof Float64Array === "undefined" ? undefined : Float64Array,
  1210. "%FinalizationRegistry%":
  1211. typeof FinalizationRegistry === "undefined"
  1212. ? undefined
  1213. : FinalizationRegistry,
  1214. "%Function%": $Function,
  1215. "%GeneratorFunction%": needsEval,
  1216. "%Int8Array%":
  1217. typeof Int8Array === "undefined" ? undefined : Int8Array,
  1218. "%Int16Array%":
  1219. typeof Int16Array === "undefined" ? undefined : Int16Array,
  1220. "%Int32Array%":
  1221. typeof Int32Array === "undefined" ? undefined : Int32Array,
  1222. "%isFinite%": isFinite,
  1223. "%isNaN%": isNaN,
  1224. "%IteratorPrototype%": hasSymbols
  1225. ? getProto(getProto([][Symbol.iterator]()))
  1226. : undefined,
  1227. "%JSON%": typeof JSON === "object" ? JSON : undefined,
  1228. "%Map%": typeof Map === "undefined" ? undefined : Map,
  1229. "%MapIteratorPrototype%":
  1230. typeof Map === "undefined" || !hasSymbols
  1231. ? undefined
  1232. : getProto(new Map()[Symbol.iterator]()),
  1233. "%Math%": Math,
  1234. "%Number%": Number,
  1235. "%Object%": Object,
  1236. "%parseFloat%": parseFloat,
  1237. "%parseInt%": parseInt,
  1238. "%Promise%": typeof Promise === "undefined" ? undefined : Promise,
  1239. "%Proxy%": typeof Proxy === "undefined" ? undefined : Proxy,
  1240. "%RangeError%": RangeError,
  1241. "%ReferenceError%": ReferenceError,
  1242. "%Reflect%": typeof Reflect === "undefined" ? undefined : Reflect,
  1243. "%RegExp%": RegExp,
  1244. "%Set%": typeof Set === "undefined" ? undefined : Set,
  1245. "%SetIteratorPrototype%":
  1246. typeof Set === "undefined" || !hasSymbols
  1247. ? undefined
  1248. : getProto(new Set()[Symbol.iterator]()),
  1249. "%SharedArrayBuffer%":
  1250. typeof SharedArrayBuffer === "undefined"
  1251. ? undefined
  1252. : SharedArrayBuffer,
  1253. "%String%": String,
  1254. "%StringIteratorPrototype%": hasSymbols
  1255. ? getProto(""[Symbol.iterator]())
  1256. : undefined,
  1257. "%Symbol%": hasSymbols ? Symbol : undefined,
  1258. "%SyntaxError%": $SyntaxError,
  1259. "%ThrowTypeError%": ThrowTypeError,
  1260. "%TypedArray%": TypedArray,
  1261. "%TypeError%": $TypeError,
  1262. "%Uint8Array%":
  1263. typeof Uint8Array === "undefined" ? undefined : Uint8Array,
  1264. "%Uint8ClampedArray%":
  1265. typeof Uint8ClampedArray === "undefined"
  1266. ? undefined
  1267. : Uint8ClampedArray,
  1268. "%Uint16Array%":
  1269. typeof Uint16Array === "undefined" ? undefined : Uint16Array,
  1270. "%Uint32Array%":
  1271. typeof Uint32Array === "undefined" ? undefined : Uint32Array,
  1272. "%URIError%": URIError,
  1273. "%WeakMap%": typeof WeakMap === "undefined" ? undefined : WeakMap,
  1274. "%WeakRef%": typeof WeakRef === "undefined" ? undefined : WeakRef,
  1275. "%WeakSet%": typeof WeakSet === "undefined" ? undefined : WeakSet,
  1276. };
  1277. var doEval = function doEval(name) {
  1278. var value;
  1279. if (name === "%AsyncFunction%") {
  1280. value = getEvalledConstructor("async function () {}");
  1281. } else if (name === "%GeneratorFunction%") {
  1282. value = getEvalledConstructor("function* () {}");
  1283. } else if (name === "%AsyncGeneratorFunction%") {
  1284. value = getEvalledConstructor("async function* () {}");
  1285. } else if (name === "%AsyncGenerator%") {
  1286. var fn = doEval("%AsyncGeneratorFunction%");
  1287. if (fn) {
  1288. value = fn.prototype;
  1289. }
  1290. } else if (name === "%AsyncIteratorPrototype%") {
  1291. var gen = doEval("%AsyncGenerator%");
  1292. if (gen) {
  1293. value = getProto(gen.prototype);
  1294. }
  1295. }
  1296. INTRINSICS[name] = value;
  1297. return value;
  1298. };
  1299. var LEGACY_ALIASES = {
  1300. "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
  1301. "%ArrayPrototype%": ["Array", "prototype"],
  1302. "%ArrayProto_entries%": ["Array", "prototype", "entries"],
  1303. "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
  1304. "%ArrayProto_keys%": ["Array", "prototype", "keys"],
  1305. "%ArrayProto_values%": ["Array", "prototype", "values"],
  1306. "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
  1307. "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
  1308. "%AsyncGeneratorPrototype%": [
  1309. "AsyncGeneratorFunction",
  1310. "prototype",
  1311. "prototype",
  1312. ],
  1313. "%BooleanPrototype%": ["Boolean", "prototype"],
  1314. "%DataViewPrototype%": ["DataView", "prototype"],
  1315. "%DatePrototype%": ["Date", "prototype"],
  1316. "%ErrorPrototype%": ["Error", "prototype"],
  1317. "%EvalErrorPrototype%": ["EvalError", "prototype"],
  1318. "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
  1319. "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
  1320. "%FunctionPrototype%": ["Function", "prototype"],
  1321. "%Generator%": ["GeneratorFunction", "prototype"],
  1322. "%GeneratorPrototype%": [
  1323. "GeneratorFunction",
  1324. "prototype",
  1325. "prototype",
  1326. ],
  1327. "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
  1328. "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
  1329. "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
  1330. "%JSONParse%": ["JSON", "parse"],
  1331. "%JSONStringify%": ["JSON", "stringify"],
  1332. "%MapPrototype%": ["Map", "prototype"],
  1333. "%NumberPrototype%": ["Number", "prototype"],
  1334. "%ObjectPrototype%": ["Object", "prototype"],
  1335. "%ObjProto_toString%": ["Object", "prototype", "toString"],
  1336. "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
  1337. "%PromisePrototype%": ["Promise", "prototype"],
  1338. "%PromiseProto_then%": ["Promise", "prototype", "then"],
  1339. "%Promise_all%": ["Promise", "all"],
  1340. "%Promise_reject%": ["Promise", "reject"],
  1341. "%Promise_resolve%": ["Promise", "resolve"],
  1342. "%RangeErrorPrototype%": ["RangeError", "prototype"],
  1343. "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
  1344. "%RegExpPrototype%": ["RegExp", "prototype"],
  1345. "%SetPrototype%": ["Set", "prototype"],
  1346. "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
  1347. "%StringPrototype%": ["String", "prototype"],
  1348. "%SymbolPrototype%": ["Symbol", "prototype"],
  1349. "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
  1350. "%TypedArrayPrototype%": ["TypedArray", "prototype"],
  1351. "%TypeErrorPrototype%": ["TypeError", "prototype"],
  1352. "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
  1353. "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
  1354. "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
  1355. "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
  1356. "%URIErrorPrototype%": ["URIError", "prototype"],
  1357. "%WeakMapPrototype%": ["WeakMap", "prototype"],
  1358. "%WeakSetPrototype%": ["WeakSet", "prototype"],
  1359. };
  1360. var bind = require("function-bind");
  1361. var hasOwn = require("has");
  1362. var $concat = bind.call(Function.call, Array.prototype.concat);
  1363. var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
  1364. var $replace = bind.call(Function.call, String.prototype.replace);
  1365. var $strSlice = bind.call(Function.call, String.prototype.slice);
  1366. /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
  1367. var rePropName =
  1368. /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  1369. var reEscapeChar =
  1370. /\\(\\)?/g; /** Used to match backslashes in property paths. */
  1371. var stringToPath = function stringToPath(string) {
  1372. var first = $strSlice(string, 0, 1);
  1373. var last = $strSlice(string, -1);
  1374. if (first === "%" && last !== "%") {
  1375. throw new $SyntaxError(
  1376. "invalid intrinsic syntax, expected closing `%`"
  1377. );
  1378. } else if (last === "%" && first !== "%") {
  1379. throw new $SyntaxError(
  1380. "invalid intrinsic syntax, expected opening `%`"
  1381. );
  1382. }
  1383. var result = [];
  1384. $replace(
  1385. string,
  1386. rePropName,
  1387. function (match, number, quote, subString) {
  1388. result[result.length] = quote
  1389. ? $replace(subString, reEscapeChar, "$1")
  1390. : number || match;
  1391. }
  1392. );
  1393. return result;
  1394. };
  1395. /* end adaptation */
  1396. var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
  1397. var intrinsicName = name;
  1398. var alias;
  1399. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  1400. alias = LEGACY_ALIASES[intrinsicName];
  1401. intrinsicName = "%" + alias[0] + "%";
  1402. }
  1403. if (hasOwn(INTRINSICS, intrinsicName)) {
  1404. var value = INTRINSICS[intrinsicName];
  1405. if (value === needsEval) {
  1406. value = doEval(intrinsicName);
  1407. }
  1408. if (typeof value === "undefined" && !allowMissing) {
  1409. throw new $TypeError(
  1410. "intrinsic " +
  1411. name +
  1412. " exists, but is not available. Please file an issue!"
  1413. );
  1414. }
  1415. return {
  1416. alias: alias,
  1417. name: intrinsicName,
  1418. value: value,
  1419. };
  1420. }
  1421. throw new $SyntaxError("intrinsic " + name + " does not exist!");
  1422. };
  1423. module.exports = function GetIntrinsic(name, allowMissing) {
  1424. if (typeof name !== "string" || name.length === 0) {
  1425. throw new $TypeError("intrinsic name must be a non-empty string");
  1426. }
  1427. if (arguments.length > 1 && typeof allowMissing !== "boolean") {
  1428. throw new $TypeError('"allowMissing" argument must be a boolean');
  1429. }
  1430. var parts = stringToPath(name);
  1431. var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
  1432. var intrinsic = getBaseIntrinsic(
  1433. "%" + intrinsicBaseName + "%",
  1434. allowMissing
  1435. );
  1436. var intrinsicRealName = intrinsic.name;
  1437. var value = intrinsic.value;
  1438. var skipFurtherCaching = false;
  1439. var alias = intrinsic.alias;
  1440. if (alias) {
  1441. intrinsicBaseName = alias[0];
  1442. $spliceApply(parts, $concat([0, 1], alias));
  1443. }
  1444. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  1445. var part = parts[i];
  1446. var first = $strSlice(part, 0, 1);
  1447. var last = $strSlice(part, -1);
  1448. if (
  1449. (first === '"' ||
  1450. first === "'" ||
  1451. first === "`" ||
  1452. last === '"' ||
  1453. last === "'" ||
  1454. last === "`") &&
  1455. first !== last
  1456. ) {
  1457. throw new $SyntaxError(
  1458. "property names with quotes must have matching quotes"
  1459. );
  1460. }
  1461. if (part === "constructor" || !isOwn) {
  1462. skipFurtherCaching = true;
  1463. }
  1464. intrinsicBaseName += "." + part;
  1465. intrinsicRealName = "%" + intrinsicBaseName + "%";
  1466. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  1467. value = INTRINSICS[intrinsicRealName];
  1468. } else if (value != null) {
  1469. if (!(part in value)) {
  1470. if (!allowMissing) {
  1471. throw new $TypeError(
  1472. "base intrinsic for " +
  1473. name +
  1474. " exists, but the property is not available."
  1475. );
  1476. }
  1477. return void undefined;
  1478. }
  1479. if ($gOPD && i + 1 >= parts.length) {
  1480. var desc = $gOPD(value, part);
  1481. isOwn = !!desc;
  1482. // By convention, when a data property is converted to an accessor
  1483. // property to emulate a data property that does not suffer from
  1484. // the override mistake, that accessor's getter is marked with
  1485. // an `originalValue` property. Here, when we detect this, we
  1486. // uphold the illusion by pretending to see that original data
  1487. // property, i.e., returning the value rather than the getter
  1488. // itself.
  1489. if (
  1490. isOwn &&
  1491. "get" in desc &&
  1492. !("originalValue" in desc.get)
  1493. ) {
  1494. value = desc.get;
  1495. } else {
  1496. value = value[part];
  1497. }
  1498. } else {
  1499. isOwn = hasOwn(value, part);
  1500. value = value[part];
  1501. }
  1502. if (isOwn && !skipFurtherCaching) {
  1503. INTRINSICS[intrinsicRealName] = value;
  1504. }
  1505. }
  1506. }
  1507. return value;
  1508. };
  1509. },
  1510. { "function-bind": 10, has: 14, "has-symbols": 12 },
  1511. ],
  1512. 12: [
  1513. function (require, module, exports) {
  1514. "use strict";
  1515. var origSymbol = typeof Symbol !== "undefined" && Symbol;
  1516. var hasSymbolSham = require("./shams");
  1517. module.exports = function hasNativeSymbols() {
  1518. if (typeof origSymbol !== "function") {
  1519. return false;
  1520. }
  1521. if (typeof Symbol !== "function") {
  1522. return false;
  1523. }
  1524. if (typeof origSymbol("foo") !== "symbol") {
  1525. return false;
  1526. }
  1527. if (typeof Symbol("bar") !== "symbol") {
  1528. return false;
  1529. }
  1530. return hasSymbolSham();
  1531. };
  1532. },
  1533. { "./shams": 13 },
  1534. ],
  1535. 13: [
  1536. function (require, module, exports) {
  1537. "use strict";
  1538. /* eslint complexity: [2, 18], max-statements: [2, 33] */
  1539. module.exports = function hasSymbols() {
  1540. if (
  1541. typeof Symbol !== "function" ||
  1542. typeof Object.getOwnPropertySymbols !== "function"
  1543. ) {
  1544. return false;
  1545. }
  1546. if (typeof Symbol.iterator === "symbol") {
  1547. return true;
  1548. }
  1549. var obj = {};
  1550. var sym = Symbol("test");
  1551. var symObj = Object(sym);
  1552. if (typeof sym === "string") {
  1553. return false;
  1554. }
  1555. if (Object.prototype.toString.call(sym) !== "[object Symbol]") {
  1556. return false;
  1557. }
  1558. if (Object.prototype.toString.call(symObj) !== "[object Symbol]") {
  1559. return false;
  1560. }
  1561. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  1562. // if (sym instanceof Symbol) { return false; }
  1563. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  1564. // if (!(symObj instanceof Symbol)) { return false; }
  1565. // if (typeof Symbol.prototype.toString !== 'function') { return false; }
  1566. // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
  1567. var symVal = 42;
  1568. obj[sym] = symVal;
  1569. for (sym in obj) {
  1570. return false;
  1571. } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
  1572. if (
  1573. typeof Object.keys === "function" &&
  1574. Object.keys(obj).length !== 0
  1575. ) {
  1576. return false;
  1577. }
  1578. if (
  1579. typeof Object.getOwnPropertyNames === "function" &&
  1580. Object.getOwnPropertyNames(obj).length !== 0
  1581. ) {
  1582. return false;
  1583. }
  1584. var syms = Object.getOwnPropertySymbols(obj);
  1585. if (syms.length !== 1 || syms[0] !== sym) {
  1586. return false;
  1587. }
  1588. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
  1589. return false;
  1590. }
  1591. if (typeof Object.getOwnPropertyDescriptor === "function") {
  1592. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  1593. if (
  1594. descriptor.value !== symVal ||
  1595. descriptor.enumerable !== true
  1596. ) {
  1597. return false;
  1598. }
  1599. }
  1600. return true;
  1601. };
  1602. },
  1603. {},
  1604. ],
  1605. 14: [
  1606. function (require, module, exports) {
  1607. "use strict";
  1608. var bind = require("function-bind");
  1609. module.exports = bind.call(
  1610. Function.call,
  1611. Object.prototype.hasOwnProperty
  1612. );
  1613. },
  1614. { "function-bind": 10 },
  1615. ],
  1616. 15: [
  1617. function (require, module, exports) {
  1618. var hasMap = typeof Map === "function" && Map.prototype;
  1619. var mapSizeDescriptor =
  1620. Object.getOwnPropertyDescriptor && hasMap
  1621. ? Object.getOwnPropertyDescriptor(Map.prototype, "size")
  1622. : null;
  1623. var mapSize =
  1624. hasMap &&
  1625. mapSizeDescriptor &&
  1626. typeof mapSizeDescriptor.get === "function"
  1627. ? mapSizeDescriptor.get
  1628. : null;
  1629. var mapForEach = hasMap && Map.prototype.forEach;
  1630. var hasSet = typeof Set === "function" && Set.prototype;
  1631. var setSizeDescriptor =
  1632. Object.getOwnPropertyDescriptor && hasSet
  1633. ? Object.getOwnPropertyDescriptor(Set.prototype, "size")
  1634. : null;
  1635. var setSize =
  1636. hasSet &&
  1637. setSizeDescriptor &&
  1638. typeof setSizeDescriptor.get === "function"
  1639. ? setSizeDescriptor.get
  1640. : null;
  1641. var setForEach = hasSet && Set.prototype.forEach;
  1642. var hasWeakMap = typeof WeakMap === "function" && WeakMap.prototype;
  1643. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  1644. var hasWeakSet = typeof WeakSet === "function" && WeakSet.prototype;
  1645. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  1646. var booleanValueOf = Boolean.prototype.valueOf;
  1647. var objectToString = Object.prototype.toString;
  1648. var functionToString = Function.prototype.toString;
  1649. var match = String.prototype.match;
  1650. var bigIntValueOf =
  1651. typeof BigInt === "function" ? BigInt.prototype.valueOf : null;
  1652. var gOPS = Object.getOwnPropertySymbols;
  1653. var symToString =
  1654. typeof Symbol === "function" ? Symbol.prototype.toString : null;
  1655. var isEnumerable = Object.prototype.propertyIsEnumerable;
  1656. var inspectCustom = require("./util.inspect").custom;
  1657. var inspectSymbol =
  1658. inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
  1659. module.exports = function inspect_(obj, options, depth, seen) {
  1660. var opts = options || {};
  1661. if (
  1662. has(opts, "quoteStyle") &&
  1663. opts.quoteStyle !== "single" &&
  1664. opts.quoteStyle !== "double"
  1665. ) {
  1666. throw new TypeError(
  1667. 'option "quoteStyle" must be "single" or "double"'
  1668. );
  1669. }
  1670. if (
  1671. has(opts, "maxStringLength") &&
  1672. (typeof opts.maxStringLength === "number"
  1673. ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
  1674. : opts.maxStringLength !== null)
  1675. ) {
  1676. throw new TypeError(
  1677. 'option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`'
  1678. );
  1679. }
  1680. var customInspect = has(opts, "customInspect")
  1681. ? opts.customInspect
  1682. : true;
  1683. if (typeof customInspect !== "boolean") {
  1684. throw new TypeError(
  1685. 'option "customInspect", if provided, must be `true` or `false`'
  1686. );
  1687. }
  1688. if (
  1689. has(opts, "indent") &&
  1690. opts.indent !== null &&
  1691. opts.indent !== "\t" &&
  1692. !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
  1693. ) {
  1694. throw new TypeError(
  1695. 'options "indent" must be "\\t", an integer > 0, or `null`'
  1696. );
  1697. }
  1698. if (typeof obj === "undefined") {
  1699. return "undefined";
  1700. }
  1701. if (obj === null) {
  1702. return "null";
  1703. }
  1704. if (typeof obj === "boolean") {
  1705. return obj ? "true" : "false";
  1706. }
  1707. if (typeof obj === "string") {
  1708. return inspectString(obj, opts);
  1709. }
  1710. if (typeof obj === "number") {
  1711. if (obj === 0) {
  1712. return Infinity / obj > 0 ? "0" : "-0";
  1713. }
  1714. return String(obj);
  1715. }
  1716. if (typeof obj === "bigint") {
  1717. return String(obj) + "n";
  1718. }
  1719. var maxDepth = typeof opts.depth === "undefined" ? 5 : opts.depth;
  1720. if (typeof depth === "undefined") {
  1721. depth = 0;
  1722. }
  1723. if (depth >= maxDepth && maxDepth > 0 && typeof obj === "object") {
  1724. return isArray(obj) ? "[Array]" : "[Object]";
  1725. }
  1726. var indent = getIndent(opts, depth);
  1727. if (typeof seen === "undefined") {
  1728. seen = [];
  1729. } else if (indexOf(seen, obj) >= 0) {
  1730. return "[Circular]";
  1731. }
  1732. function inspect(value, from, noIndent) {
  1733. if (from) {
  1734. seen = seen.slice();
  1735. seen.push(from);
  1736. }
  1737. if (noIndent) {
  1738. var newOpts = {
  1739. depth: opts.depth,
  1740. };
  1741. if (has(opts, "quoteStyle")) {
  1742. newOpts.quoteStyle = opts.quoteStyle;
  1743. }
  1744. return inspect_(value, newOpts, depth + 1, seen);
  1745. }
  1746. return inspect_(value, opts, depth + 1, seen);
  1747. }
  1748. if (typeof obj === "function") {
  1749. var name = nameOf(obj);
  1750. var keys = arrObjKeys(obj, inspect);
  1751. return (
  1752. "[Function" +
  1753. (name ? ": " + name : " (anonymous)") +
  1754. "]" +
  1755. (keys.length > 0 ? " { " + keys.join(", ") + " }" : "")
  1756. );
  1757. }
  1758. if (isSymbol(obj)) {
  1759. var symString = symToString.call(obj);
  1760. return typeof obj === "object" ? markBoxed(symString) : symString;
  1761. }
  1762. if (isElement(obj)) {
  1763. var s = "<" + String(obj.nodeName).toLowerCase();
  1764. var attrs = obj.attributes || [];
  1765. for (var i = 0; i < attrs.length; i++) {
  1766. s +=
  1767. " " +
  1768. attrs[i].name +
  1769. "=" +
  1770. wrapQuotes(quote(attrs[i].value), "double", opts);
  1771. }
  1772. s += ">";
  1773. if (obj.childNodes && obj.childNodes.length) {
  1774. s += "...";
  1775. }
  1776. s += "</" + String(obj.nodeName).toLowerCase() + ">";
  1777. return s;
  1778. }
  1779. if (isArray(obj)) {
  1780. if (obj.length === 0) {
  1781. return "[]";
  1782. }
  1783. var xs = arrObjKeys(obj, inspect);
  1784. if (indent && !singleLineValues(xs)) {
  1785. return "[" + indentedJoin(xs, indent) + "]";
  1786. }
  1787. return "[ " + xs.join(", ") + " ]";
  1788. }
  1789. if (isError(obj)) {
  1790. var parts = arrObjKeys(obj, inspect);
  1791. if (parts.length === 0) {
  1792. return "[" + String(obj) + "]";
  1793. }
  1794. return "{ [" + String(obj) + "] " + parts.join(", ") + " }";
  1795. }
  1796. if (typeof obj === "object" && customInspect) {
  1797. if (inspectSymbol && typeof obj[inspectSymbol] === "function") {
  1798. return obj[inspectSymbol]();
  1799. } else if (typeof obj.inspect === "function") {
  1800. return obj.inspect();
  1801. }
  1802. }
  1803. if (isMap(obj)) {
  1804. var mapParts = [];
  1805. mapForEach.call(obj, function (value, key) {
  1806. mapParts.push(
  1807. inspect(key, obj, true) + " => " + inspect(value, obj)
  1808. );
  1809. });
  1810. return collectionOf("Map", mapSize.call(obj), mapParts, indent);
  1811. }
  1812. if (isSet(obj)) {
  1813. var setParts = [];
  1814. setForEach.call(obj, function (value) {
  1815. setParts.push(inspect(value, obj));
  1816. });
  1817. return collectionOf("Set", setSize.call(obj), setParts, indent);
  1818. }
  1819. if (isWeakMap(obj)) {
  1820. return weakCollectionOf("WeakMap");
  1821. }
  1822. if (isWeakSet(obj)) {
  1823. return weakCollectionOf("WeakSet");
  1824. }
  1825. if (isNumber(obj)) {
  1826. return markBoxed(inspect(Number(obj)));
  1827. }
  1828. if (isBigInt(obj)) {
  1829. return markBoxed(inspect(bigIntValueOf.call(obj)));
  1830. }
  1831. if (isBoolean(obj)) {
  1832. return markBoxed(booleanValueOf.call(obj));
  1833. }
  1834. if (isString(obj)) {
  1835. return markBoxed(inspect(String(obj)));
  1836. }
  1837. if (!isDate(obj) && !isRegExp(obj)) {
  1838. var ys = arrObjKeys(obj, inspect);
  1839. if (ys.length === 0) {
  1840. return "{}";
  1841. }
  1842. if (indent) {
  1843. return "{" + indentedJoin(ys, indent) + "}";
  1844. }
  1845. return "{ " + ys.join(", ") + " }";
  1846. }
  1847. return String(obj);
  1848. };
  1849. function wrapQuotes(s, defaultStyle, opts) {
  1850. var quoteChar =
  1851. (opts.quoteStyle || defaultStyle) === "double" ? '"' : "'";
  1852. return quoteChar + s + quoteChar;
  1853. }
  1854. function quote(s) {
  1855. return String(s).replace(/"/g, "&quot;");
  1856. }
  1857. function isArray(obj) {
  1858. return toStr(obj) === "[object Array]";
  1859. }
  1860. function isDate(obj) {
  1861. return toStr(obj) === "[object Date]";
  1862. }
  1863. function isRegExp(obj) {
  1864. return toStr(obj) === "[object RegExp]";
  1865. }
  1866. function isError(obj) {
  1867. return toStr(obj) === "[object Error]";
  1868. }
  1869. function isSymbol(obj) {
  1870. return toStr(obj) === "[object Symbol]";
  1871. }
  1872. function isString(obj) {
  1873. return toStr(obj) === "[object String]";
  1874. }
  1875. function isNumber(obj) {
  1876. return toStr(obj) === "[object Number]";
  1877. }
  1878. function isBigInt(obj) {
  1879. return toStr(obj) === "[object BigInt]";
  1880. }
  1881. function isBoolean(obj) {
  1882. return toStr(obj) === "[object Boolean]";
  1883. }
  1884. var hasOwn =
  1885. Object.prototype.hasOwnProperty ||
  1886. function (key) {
  1887. return key in this;
  1888. };
  1889. function has(obj, key) {
  1890. return hasOwn.call(obj, key);
  1891. }
  1892. function toStr(obj) {
  1893. return objectToString.call(obj);
  1894. }
  1895. function nameOf(f) {
  1896. if (f.name) {
  1897. return f.name;
  1898. }
  1899. var m = match.call(
  1900. functionToString.call(f),
  1901. /^function\s*([\w$]+)/
  1902. );
  1903. if (m) {
  1904. return m[1];
  1905. }
  1906. return null;
  1907. }
  1908. function indexOf(xs, x) {
  1909. if (xs.indexOf) {
  1910. return xs.indexOf(x);
  1911. }
  1912. for (var i = 0, l = xs.length; i < l; i++) {
  1913. if (xs[i] === x) {
  1914. return i;
  1915. }
  1916. }
  1917. return -1;
  1918. }
  1919. function isMap(x) {
  1920. if (!mapSize || !x || typeof x !== "object") {
  1921. return false;
  1922. }
  1923. try {
  1924. mapSize.call(x);
  1925. try {
  1926. setSize.call(x);
  1927. } catch (s) {
  1928. return true;
  1929. }
  1930. return x instanceof Map; // core-js workaround, pre-v2.5.0
  1931. } catch (e) {}
  1932. return false;
  1933. }
  1934. function isWeakMap(x) {
  1935. if (!weakMapHas || !x || typeof x !== "object") {
  1936. return false;
  1937. }
  1938. try {
  1939. weakMapHas.call(x, weakMapHas);
  1940. try {
  1941. weakSetHas.call(x, weakSetHas);
  1942. } catch (s) {
  1943. return true;
  1944. }
  1945. return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
  1946. } catch (e) {}
  1947. return false;
  1948. }
  1949. function isSet(x) {
  1950. if (!setSize || !x || typeof x !== "object") {
  1951. return false;
  1952. }
  1953. try {
  1954. setSize.call(x);
  1955. try {
  1956. mapSize.call(x);
  1957. } catch (m) {
  1958. return true;
  1959. }
  1960. return x instanceof Set; // core-js workaround, pre-v2.5.0
  1961. } catch (e) {}
  1962. return false;
  1963. }
  1964. function isWeakSet(x) {
  1965. if (!weakSetHas || !x || typeof x !== "object") {
  1966. return false;
  1967. }
  1968. try {
  1969. weakSetHas.call(x, weakSetHas);
  1970. try {
  1971. weakMapHas.call(x, weakMapHas);
  1972. } catch (s) {
  1973. return true;
  1974. }
  1975. return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
  1976. } catch (e) {}
  1977. return false;
  1978. }
  1979. function isElement(x) {
  1980. if (!x || typeof x !== "object") {
  1981. return false;
  1982. }
  1983. if (
  1984. typeof HTMLElement !== "undefined" &&
  1985. x instanceof HTMLElement
  1986. ) {
  1987. return true;
  1988. }
  1989. return (
  1990. typeof x.nodeName === "string" &&
  1991. typeof x.getAttribute === "function"
  1992. );
  1993. }
  1994. function inspectString(str, opts) {
  1995. if (str.length > opts.maxStringLength) {
  1996. var remaining = str.length - opts.maxStringLength;
  1997. var trailer =
  1998. "... " +
  1999. remaining +
  2000. " more character" +
  2001. (remaining > 1 ? "s" : "");
  2002. return (
  2003. inspectString(str.slice(0, opts.maxStringLength), opts) +
  2004. trailer
  2005. );
  2006. }
  2007. // eslint-disable-next-line no-control-regex
  2008. var s = str
  2009. .replace(/(['\\])/g, "\\$1")
  2010. .replace(/[\x00-\x1f]/g, lowbyte);
  2011. return wrapQuotes(s, "single", opts);
  2012. }
  2013. function lowbyte(c) {
  2014. var n = c.charCodeAt(0);
  2015. var x = {
  2016. 8: "b",
  2017. 9: "t",
  2018. 10: "n",
  2019. 12: "f",
  2020. 13: "r",
  2021. }[n];
  2022. if (x) {
  2023. return "\\" + x;
  2024. }
  2025. return "\\x" + (n < 0x10 ? "0" : "") + n.toString(16).toUpperCase();
  2026. }
  2027. function markBoxed(str) {
  2028. return "Object(" + str + ")";
  2029. }
  2030. function weakCollectionOf(type) {
  2031. return type + " { ? }";
  2032. }
  2033. function collectionOf(type, size, entries, indent) {
  2034. var joinedEntries = indent
  2035. ? indentedJoin(entries, indent)
  2036. : entries.join(", ");
  2037. return type + " (" + size + ") {" + joinedEntries + "}";
  2038. }
  2039. function singleLineValues(xs) {
  2040. for (var i = 0; i < xs.length; i++) {
  2041. if (indexOf(xs[i], "\n") >= 0) {
  2042. return false;
  2043. }
  2044. }
  2045. return true;
  2046. }
  2047. function getIndent(opts, depth) {
  2048. var baseIndent;
  2049. if (opts.indent === "\t") {
  2050. baseIndent = "\t";
  2051. } else if (typeof opts.indent === "number" && opts.indent > 0) {
  2052. baseIndent = Array(opts.indent + 1).join(" ");
  2053. } else {
  2054. return null;
  2055. }
  2056. return {
  2057. base: baseIndent,
  2058. prev: Array(depth + 1).join(baseIndent),
  2059. };
  2060. }
  2061. function indentedJoin(xs, indent) {
  2062. if (xs.length === 0) {
  2063. return "";
  2064. }
  2065. var lineJoiner = "\n" + indent.prev + indent.base;
  2066. return lineJoiner + xs.join("," + lineJoiner) + "\n" + indent.prev;
  2067. }
  2068. function arrObjKeys(obj, inspect) {
  2069. var isArr = isArray(obj);
  2070. var xs = [];
  2071. if (isArr) {
  2072. xs.length = obj.length;
  2073. for (var i = 0; i < obj.length; i++) {
  2074. xs[i] = has(obj, i) ? inspect(obj[i], obj) : "";
  2075. }
  2076. }
  2077. for (var key in obj) {
  2078. // eslint-disable-line no-restricted-syntax
  2079. if (!has(obj, key)) {
  2080. continue;
  2081. } // eslint-disable-line no-restricted-syntax, no-continue
  2082. if (isArr && String(Number(key)) === key && key < obj.length) {
  2083. continue;
  2084. } // eslint-disable-line no-restricted-syntax, no-continue
  2085. if (/[^\w$]/.test(key)) {
  2086. xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj));
  2087. } else {
  2088. xs.push(key + ": " + inspect(obj[key], obj));
  2089. }
  2090. }
  2091. if (typeof gOPS === "function") {
  2092. var syms = gOPS(obj);
  2093. for (var j = 0; j < syms.length; j++) {
  2094. if (isEnumerable.call(obj, syms[j])) {
  2095. xs.push(
  2096. "[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj)
  2097. );
  2098. }
  2099. }
  2100. }
  2101. return xs;
  2102. }
  2103. },
  2104. { "./util.inspect": 6 },
  2105. ],
  2106. 16: [
  2107. function (require, module, exports) {
  2108. "use strict";
  2109. var GetIntrinsic = require("get-intrinsic");
  2110. var callBound = require("call-bind/callBound");
  2111. var inspect = require("object-inspect");
  2112. var $TypeError = GetIntrinsic("%TypeError%");
  2113. var $WeakMap = GetIntrinsic("%WeakMap%", true);
  2114. var $Map = GetIntrinsic("%Map%", true);
  2115. var $weakMapGet = callBound("WeakMap.prototype.get", true);
  2116. var $weakMapSet = callBound("WeakMap.prototype.set", true);
  2117. var $weakMapHas = callBound("WeakMap.prototype.has", true);
  2118. var $mapGet = callBound("Map.prototype.get", true);
  2119. var $mapSet = callBound("Map.prototype.set", true);
  2120. var $mapHas = callBound("Map.prototype.has", true);
  2121. /*
  2122. * This function traverses the list returning the node corresponding to the
  2123. * given key.
  2124. *
  2125. * That node is also moved to the head of the list, so that if it's accessed
  2126. * again we don't need to traverse the whole list. By doing so, all the recently
  2127. * used nodes can be accessed relatively quickly.
  2128. */
  2129. var listGetNode = function (list, key) {
  2130. // eslint-disable-line consistent-return
  2131. for (
  2132. var prev = list, curr;
  2133. (curr = prev.next) !== null;
  2134. prev = curr
  2135. ) {
  2136. if (curr.key === key) {
  2137. prev.next = curr.next;
  2138. curr.next = list.next;
  2139. list.next = curr; // eslint-disable-line no-param-reassign
  2140. return curr;
  2141. }
  2142. }
  2143. };
  2144. var listGet = function (objects, key) {
  2145. var node = listGetNode(objects, key);
  2146. return node && node.value;
  2147. };
  2148. var listSet = function (objects, key, value) {
  2149. var node = listGetNode(objects, key);
  2150. if (node) {
  2151. node.value = value;
  2152. } else {
  2153. // Prepend the new node to the beginning of the list
  2154. objects.next = {
  2155. // eslint-disable-line no-param-reassign
  2156. key: key,
  2157. next: objects.next,
  2158. value: value,
  2159. };
  2160. }
  2161. };
  2162. var listHas = function (objects, key) {
  2163. return !!listGetNode(objects, key);
  2164. };
  2165. module.exports = function getSideChannel() {
  2166. var $wm;
  2167. var $m;
  2168. var $o;
  2169. var channel = {
  2170. assert: function (key) {
  2171. if (!channel.has(key)) {
  2172. throw new $TypeError(
  2173. "Side channel does not contain " + inspect(key)
  2174. );
  2175. }
  2176. },
  2177. get: function (key) {
  2178. // eslint-disable-line consistent-return
  2179. if (
  2180. $WeakMap &&
  2181. key &&
  2182. (typeof key === "object" || typeof key === "function")
  2183. ) {
  2184. if ($wm) {
  2185. return $weakMapGet($wm, key);
  2186. }
  2187. } else if ($Map) {
  2188. if ($m) {
  2189. return $mapGet($m, key);
  2190. }
  2191. } else {
  2192. if ($o) {
  2193. // eslint-disable-line no-lonely-if
  2194. return listGet($o, key);
  2195. }
  2196. }
  2197. },
  2198. has: function (key) {
  2199. if (
  2200. $WeakMap &&
  2201. key &&
  2202. (typeof key === "object" || typeof key === "function")
  2203. ) {
  2204. if ($wm) {
  2205. return $weakMapHas($wm, key);
  2206. }
  2207. } else if ($Map) {
  2208. if ($m) {
  2209. return $mapHas($m, key);
  2210. }
  2211. } else {
  2212. if ($o) {
  2213. // eslint-disable-line no-lonely-if
  2214. return listHas($o, key);
  2215. }
  2216. }
  2217. return false;
  2218. },
  2219. set: function (key, value) {
  2220. if (
  2221. $WeakMap &&
  2222. key &&
  2223. (typeof key === "object" || typeof key === "function")
  2224. ) {
  2225. if (!$wm) {
  2226. $wm = new $WeakMap();
  2227. }
  2228. $weakMapSet($wm, key, value);
  2229. } else if ($Map) {
  2230. if (!$m) {
  2231. $m = new $Map();
  2232. }
  2233. $mapSet($m, key, value);
  2234. } else {
  2235. if (!$o) {
  2236. /*
  2237. * Initialize the linked list as an empty node, so that we don't have
  2238. * to special-case handling of the first node: we can always refer to
  2239. * it as (previous node).next, instead of something like (list).head
  2240. */
  2241. $o = { key: {}, next: null };
  2242. }
  2243. listSet($o, key, value);
  2244. }
  2245. },
  2246. };
  2247. return channel;
  2248. };
  2249. },
  2250. { "call-bind/callBound": 7, "get-intrinsic": 11, "object-inspect": 15 },
  2251. ],
  2252. },
  2253. {},
  2254. [2]
  2255. )(2);
  2256. });