superagent.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. },{}],2:[function(require,module,exports){
  3. 'use strict';
  4. var GetIntrinsic = require('get-intrinsic');
  5. var callBind = require('./');
  6. var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
  7. module.exports = function callBoundIntrinsic(name, allowMissing) {
  8. var intrinsic = GetIntrinsic(name, !!allowMissing);
  9. if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
  10. return callBind(intrinsic);
  11. }
  12. return intrinsic;
  13. };
  14. },{"./":3,"get-intrinsic":17}],3:[function(require,module,exports){
  15. 'use strict';
  16. var bind = require('function-bind');
  17. var GetIntrinsic = require('get-intrinsic');
  18. var setFunctionLength = require('set-function-length');
  19. var $TypeError = require('es-errors/type');
  20. var $apply = GetIntrinsic('%Function.prototype.apply%');
  21. var $call = GetIntrinsic('%Function.prototype.call%');
  22. var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
  23. var $defineProperty = require('es-define-property');
  24. var $max = GetIntrinsic('%Math.max%');
  25. module.exports = function callBind(originalFunction) {
  26. if (typeof originalFunction !== 'function') {
  27. throw new $TypeError('a function is required');
  28. }
  29. var func = $reflectApply(bind, $call, arguments);
  30. return setFunctionLength(func, 1 + $max(0, originalFunction.length - (arguments.length - 1)), true);
  31. };
  32. var applyBind = function applyBind() {
  33. return $reflectApply(bind, $apply, arguments);
  34. };
  35. if ($defineProperty) {
  36. $defineProperty(module.exports, 'apply', {
  37. value: applyBind
  38. });
  39. } else {
  40. module.exports.apply = applyBind;
  41. }
  42. },{"es-define-property":6,"es-errors/type":12,"function-bind":16,"get-intrinsic":17,"set-function-length":31}],4:[function(require,module,exports){
  43. if (typeof module !== 'undefined') {
  44. module.exports = Emitter;
  45. }
  46. function Emitter(obj) {
  47. if (obj) return mixin(obj);
  48. }
  49. ;
  50. function mixin(obj) {
  51. for (var key in Emitter.prototype) {
  52. obj[key] = Emitter.prototype[key];
  53. }
  54. return obj;
  55. }
  56. Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
  57. this._callbacks = this._callbacks || {};
  58. (this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
  59. return this;
  60. };
  61. Emitter.prototype.once = function (event, fn) {
  62. function on() {
  63. this.off(event, on);
  64. fn.apply(this, arguments);
  65. }
  66. on.fn = fn;
  67. this.on(event, on);
  68. return this;
  69. };
  70. Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
  71. this._callbacks = this._callbacks || {};
  72. if (0 == arguments.length) {
  73. this._callbacks = {};
  74. return this;
  75. }
  76. var callbacks = this._callbacks['$' + event];
  77. if (!callbacks) return this;
  78. if (1 == arguments.length) {
  79. delete this._callbacks['$' + event];
  80. return this;
  81. }
  82. var cb;
  83. for (var i = 0; i < callbacks.length; i++) {
  84. cb = callbacks[i];
  85. if (cb === fn || cb.fn === fn) {
  86. callbacks.splice(i, 1);
  87. break;
  88. }
  89. }
  90. if (callbacks.length === 0) {
  91. delete this._callbacks['$' + event];
  92. }
  93. return this;
  94. };
  95. Emitter.prototype.emit = function (event) {
  96. this._callbacks = this._callbacks || {};
  97. var args = new Array(arguments.length - 1),
  98. callbacks = this._callbacks['$' + event];
  99. for (var i = 1; i < arguments.length; i++) {
  100. args[i - 1] = arguments[i];
  101. }
  102. if (callbacks) {
  103. callbacks = callbacks.slice(0);
  104. for (var i = 0, len = callbacks.length; i < len; ++i) {
  105. callbacks[i].apply(this, args);
  106. }
  107. }
  108. return this;
  109. };
  110. Emitter.prototype.listeners = function (event) {
  111. this._callbacks = this._callbacks || {};
  112. return this._callbacks['$' + event] || [];
  113. };
  114. Emitter.prototype.hasListeners = function (event) {
  115. return !!this.listeners(event).length;
  116. };
  117. },{}],5:[function(require,module,exports){
  118. 'use strict';
  119. var $defineProperty = require('es-define-property');
  120. var $SyntaxError = require('es-errors/syntax');
  121. var $TypeError = require('es-errors/type');
  122. var gopd = require('gopd');
  123. module.exports = function defineDataProperty(obj, property, value) {
  124. if (!obj || typeof obj !== 'object' && typeof obj !== 'function') {
  125. throw new $TypeError('`obj` must be an object or a function`');
  126. }
  127. if (typeof property !== 'string' && typeof property !== 'symbol') {
  128. throw new $TypeError('`property` must be a string or a symbol`');
  129. }
  130. if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {
  131. throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null');
  132. }
  133. if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {
  134. throw new $TypeError('`nonWritable`, if provided, must be a boolean or null');
  135. }
  136. if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {
  137. throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null');
  138. }
  139. if (arguments.length > 6 && typeof arguments[6] !== 'boolean') {
  140. throw new $TypeError('`loose`, if provided, must be a boolean');
  141. }
  142. var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
  143. var nonWritable = arguments.length > 4 ? arguments[4] : null;
  144. var nonConfigurable = arguments.length > 5 ? arguments[5] : null;
  145. var loose = arguments.length > 6 ? arguments[6] : false;
  146. var desc = !!gopd && gopd(obj, property);
  147. if ($defineProperty) {
  148. $defineProperty(obj, property, {
  149. configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,
  150. enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,
  151. value: value,
  152. writable: nonWritable === null && desc ? desc.writable : !nonWritable
  153. });
  154. } else if (loose || !nonEnumerable && !nonWritable && !nonConfigurable) {
  155. obj[property] = value;
  156. } else {
  157. throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.');
  158. }
  159. };
  160. },{"es-define-property":6,"es-errors/syntax":11,"es-errors/type":12,"gopd":18}],6:[function(require,module,exports){
  161. 'use strict';
  162. var GetIntrinsic = require('get-intrinsic');
  163. var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false;
  164. if ($defineProperty) {
  165. try {
  166. $defineProperty({}, 'a', {
  167. value: 1
  168. });
  169. } catch (e) {
  170. $defineProperty = false;
  171. }
  172. }
  173. module.exports = $defineProperty;
  174. },{"get-intrinsic":17}],7:[function(require,module,exports){
  175. 'use strict';
  176. module.exports = EvalError;
  177. },{}],8:[function(require,module,exports){
  178. 'use strict';
  179. module.exports = Error;
  180. },{}],9:[function(require,module,exports){
  181. 'use strict';
  182. module.exports = RangeError;
  183. },{}],10:[function(require,module,exports){
  184. 'use strict';
  185. module.exports = ReferenceError;
  186. },{}],11:[function(require,module,exports){
  187. 'use strict';
  188. module.exports = SyntaxError;
  189. },{}],12:[function(require,module,exports){
  190. 'use strict';
  191. module.exports = TypeError;
  192. },{}],13:[function(require,module,exports){
  193. 'use strict';
  194. module.exports = URIError;
  195. },{}],14:[function(require,module,exports){
  196. module.exports = stringify;
  197. stringify.default = stringify;
  198. stringify.stable = deterministicStringify;
  199. stringify.stableStringify = deterministicStringify;
  200. var LIMIT_REPLACE_NODE = '[...]';
  201. var CIRCULAR_REPLACE_NODE = '[Circular]';
  202. var arr = [];
  203. var replacerStack = [];
  204. function defaultOptions() {
  205. return {
  206. depthLimit: Number.MAX_SAFE_INTEGER,
  207. edgesLimit: Number.MAX_SAFE_INTEGER
  208. };
  209. }
  210. function stringify(obj, replacer, spacer, options) {
  211. if (typeof options === 'undefined') {
  212. options = defaultOptions();
  213. }
  214. decirc(obj, '', 0, [], undefined, 0, options);
  215. var res;
  216. try {
  217. if (replacerStack.length === 0) {
  218. res = JSON.stringify(obj, replacer, spacer);
  219. } else {
  220. res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
  221. }
  222. } catch (_) {
  223. return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
  224. } finally {
  225. while (arr.length !== 0) {
  226. var part = arr.pop();
  227. if (part.length === 4) {
  228. Object.defineProperty(part[0], part[1], part[3]);
  229. } else {
  230. part[0][part[1]] = part[2];
  231. }
  232. }
  233. }
  234. return res;
  235. }
  236. function setReplace(replace, val, k, parent) {
  237. var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
  238. if (propertyDescriptor.get !== undefined) {
  239. if (propertyDescriptor.configurable) {
  240. Object.defineProperty(parent, k, {
  241. value: replace
  242. });
  243. arr.push([parent, k, val, propertyDescriptor]);
  244. } else {
  245. replacerStack.push([val, k, replace]);
  246. }
  247. } else {
  248. parent[k] = replace;
  249. arr.push([parent, k, val]);
  250. }
  251. }
  252. function decirc(val, k, edgeIndex, stack, parent, depth, options) {
  253. depth += 1;
  254. var i;
  255. if (typeof val === 'object' && val !== null) {
  256. for (i = 0; i < stack.length; i++) {
  257. if (stack[i] === val) {
  258. setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
  259. return;
  260. }
  261. }
  262. if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
  263. setReplace(LIMIT_REPLACE_NODE, val, k, parent);
  264. return;
  265. }
  266. if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
  267. setReplace(LIMIT_REPLACE_NODE, val, k, parent);
  268. return;
  269. }
  270. stack.push(val);
  271. if (Array.isArray(val)) {
  272. for (i = 0; i < val.length; i++) {
  273. decirc(val[i], i, i, stack, val, depth, options);
  274. }
  275. } else {
  276. var keys = Object.keys(val);
  277. for (i = 0; i < keys.length; i++) {
  278. var key = keys[i];
  279. decirc(val[key], key, i, stack, val, depth, options);
  280. }
  281. }
  282. stack.pop();
  283. }
  284. }
  285. function compareFunction(a, b) {
  286. if (a < b) {
  287. return -1;
  288. }
  289. if (a > b) {
  290. return 1;
  291. }
  292. return 0;
  293. }
  294. function deterministicStringify(obj, replacer, spacer, options) {
  295. if (typeof options === 'undefined') {
  296. options = defaultOptions();
  297. }
  298. var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj;
  299. var res;
  300. try {
  301. if (replacerStack.length === 0) {
  302. res = JSON.stringify(tmp, replacer, spacer);
  303. } else {
  304. res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
  305. }
  306. } catch (_) {
  307. return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
  308. } finally {
  309. while (arr.length !== 0) {
  310. var part = arr.pop();
  311. if (part.length === 4) {
  312. Object.defineProperty(part[0], part[1], part[3]);
  313. } else {
  314. part[0][part[1]] = part[2];
  315. }
  316. }
  317. }
  318. return res;
  319. }
  320. function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
  321. depth += 1;
  322. var i;
  323. if (typeof val === 'object' && val !== null) {
  324. for (i = 0; i < stack.length; i++) {
  325. if (stack[i] === val) {
  326. setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
  327. return;
  328. }
  329. }
  330. try {
  331. if (typeof val.toJSON === 'function') {
  332. return;
  333. }
  334. } catch (_) {
  335. return;
  336. }
  337. if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
  338. setReplace(LIMIT_REPLACE_NODE, val, k, parent);
  339. return;
  340. }
  341. if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
  342. setReplace(LIMIT_REPLACE_NODE, val, k, parent);
  343. return;
  344. }
  345. stack.push(val);
  346. if (Array.isArray(val)) {
  347. for (i = 0; i < val.length; i++) {
  348. deterministicDecirc(val[i], i, i, stack, val, depth, options);
  349. }
  350. } else {
  351. var tmp = {};
  352. var keys = Object.keys(val).sort(compareFunction);
  353. for (i = 0; i < keys.length; i++) {
  354. var key = keys[i];
  355. deterministicDecirc(val[key], key, i, stack, val, depth, options);
  356. tmp[key] = val[key];
  357. }
  358. if (typeof parent !== 'undefined') {
  359. arr.push([parent, k, val]);
  360. parent[k] = tmp;
  361. } else {
  362. return tmp;
  363. }
  364. }
  365. stack.pop();
  366. }
  367. }
  368. function replaceGetterValues(replacer) {
  369. replacer = typeof replacer !== 'undefined' ? replacer : function (k, v) {
  370. return v;
  371. };
  372. return function (key, val) {
  373. if (replacerStack.length > 0) {
  374. for (var i = 0; i < replacerStack.length; i++) {
  375. var part = replacerStack[i];
  376. if (part[1] === key && part[0] === val) {
  377. val = part[2];
  378. replacerStack.splice(i, 1);
  379. break;
  380. }
  381. }
  382. }
  383. return replacer.call(this, key, val);
  384. };
  385. }
  386. },{}],15:[function(require,module,exports){
  387. 'use strict';
  388. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  389. var toStr = Object.prototype.toString;
  390. var max = Math.max;
  391. var funcType = '[object Function]';
  392. var concatty = function concatty(a, b) {
  393. var arr = [];
  394. for (var i = 0; i < a.length; i += 1) {
  395. arr[i] = a[i];
  396. }
  397. for (var j = 0; j < b.length; j += 1) {
  398. arr[j + a.length] = b[j];
  399. }
  400. return arr;
  401. };
  402. var slicy = function slicy(arrLike, offset) {
  403. var arr = [];
  404. for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
  405. arr[j] = arrLike[i];
  406. }
  407. return arr;
  408. };
  409. var joiny = function (arr, joiner) {
  410. var str = '';
  411. for (var i = 0; i < arr.length; i += 1) {
  412. str += arr[i];
  413. if (i + 1 < arr.length) {
  414. str += joiner;
  415. }
  416. }
  417. return str;
  418. };
  419. module.exports = function bind(that) {
  420. var target = this;
  421. if (typeof target !== 'function' || toStr.apply(target) !== funcType) {
  422. throw new TypeError(ERROR_MESSAGE + target);
  423. }
  424. var args = slicy(arguments, 1);
  425. var bound;
  426. var binder = function () {
  427. if (this instanceof bound) {
  428. var result = target.apply(this, concatty(args, arguments));
  429. if (Object(result) === result) {
  430. return result;
  431. }
  432. return this;
  433. }
  434. return target.apply(that, concatty(args, arguments));
  435. };
  436. var boundLength = max(0, target.length - args.length);
  437. var boundArgs = [];
  438. for (var i = 0; i < boundLength; i++) {
  439. boundArgs[i] = '$' + i;
  440. }
  441. bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);
  442. if (target.prototype) {
  443. var Empty = function Empty() {};
  444. Empty.prototype = target.prototype;
  445. bound.prototype = new Empty();
  446. Empty.prototype = null;
  447. }
  448. return bound;
  449. };
  450. },{}],16:[function(require,module,exports){
  451. 'use strict';
  452. var implementation = require('./implementation');
  453. module.exports = Function.prototype.bind || implementation;
  454. },{"./implementation":15}],17:[function(require,module,exports){
  455. 'use strict';
  456. var undefined;
  457. var $Error = require('es-errors');
  458. var $EvalError = require('es-errors/eval');
  459. var $RangeError = require('es-errors/range');
  460. var $ReferenceError = require('es-errors/ref');
  461. var $SyntaxError = require('es-errors/syntax');
  462. var $TypeError = require('es-errors/type');
  463. var $URIError = require('es-errors/uri');
  464. var $Function = Function;
  465. var getEvalledConstructor = function (expressionSyntax) {
  466. try {
  467. return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
  468. } catch (e) {}
  469. };
  470. var $gOPD = Object.getOwnPropertyDescriptor;
  471. if ($gOPD) {
  472. try {
  473. $gOPD({}, '');
  474. } catch (e) {
  475. $gOPD = null;
  476. }
  477. }
  478. var throwTypeError = function () {
  479. throw new $TypeError();
  480. };
  481. var ThrowTypeError = $gOPD ? function () {
  482. try {
  483. arguments.callee;
  484. return throwTypeError;
  485. } catch (calleeThrows) {
  486. try {
  487. return $gOPD(arguments, 'callee').get;
  488. } catch (gOPDthrows) {
  489. return throwTypeError;
  490. }
  491. }
  492. }() : throwTypeError;
  493. var hasSymbols = require('has-symbols')();
  494. var hasProto = require('has-proto')();
  495. var getProto = Object.getPrototypeOf || (hasProto ? function (x) {
  496. return x.__proto__;
  497. } : null);
  498. var needsEval = {};
  499. var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined : getProto(Uint8Array);
  500. var INTRINSICS = {
  501. __proto__: null,
  502. '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
  503. '%Array%': Array,
  504. '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
  505. '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined,
  506. '%AsyncFromSyncIteratorPrototype%': undefined,
  507. '%AsyncFunction%': needsEval,
  508. '%AsyncGenerator%': needsEval,
  509. '%AsyncGeneratorFunction%': needsEval,
  510. '%AsyncIteratorPrototype%': needsEval,
  511. '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
  512. '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
  513. '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined : BigInt64Array,
  514. '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined : BigUint64Array,
  515. '%Boolean%': Boolean,
  516. '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
  517. '%Date%': Date,
  518. '%decodeURI%': decodeURI,
  519. '%decodeURIComponent%': decodeURIComponent,
  520. '%encodeURI%': encodeURI,
  521. '%encodeURIComponent%': encodeURIComponent,
  522. '%Error%': $Error,
  523. '%eval%': eval,
  524. '%EvalError%': $EvalError,
  525. '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
  526. '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
  527. '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
  528. '%Function%': $Function,
  529. '%GeneratorFunction%': needsEval,
  530. '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
  531. '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
  532. '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
  533. '%isFinite%': isFinite,
  534. '%isNaN%': isNaN,
  535. '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined,
  536. '%JSON%': typeof JSON === 'object' ? JSON : undefined,
  537. '%Map%': typeof Map === 'undefined' ? undefined : Map,
  538. '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()),
  539. '%Math%': Math,
  540. '%Number%': Number,
  541. '%Object%': Object,
  542. '%parseFloat%': parseFloat,
  543. '%parseInt%': parseInt,
  544. '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
  545. '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
  546. '%RangeError%': $RangeError,
  547. '%ReferenceError%': $ReferenceError,
  548. '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
  549. '%RegExp%': RegExp,
  550. '%Set%': typeof Set === 'undefined' ? undefined : Set,
  551. '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Set()[Symbol.iterator]()),
  552. '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
  553. '%String%': String,
  554. '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined,
  555. '%Symbol%': hasSymbols ? Symbol : undefined,
  556. '%SyntaxError%': $SyntaxError,
  557. '%ThrowTypeError%': ThrowTypeError,
  558. '%TypedArray%': TypedArray,
  559. '%TypeError%': $TypeError,
  560. '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
  561. '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
  562. '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
  563. '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
  564. '%URIError%': $URIError,
  565. '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
  566. '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
  567. '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
  568. };
  569. if (getProto) {
  570. try {
  571. null.error;
  572. } catch (e) {
  573. var errorProto = getProto(getProto(e));
  574. INTRINSICS['%Error.prototype%'] = errorProto;
  575. }
  576. }
  577. var doEval = function doEval(name) {
  578. var value;
  579. if (name === '%AsyncFunction%') {
  580. value = getEvalledConstructor('async function () {}');
  581. } else if (name === '%GeneratorFunction%') {
  582. value = getEvalledConstructor('function* () {}');
  583. } else if (name === '%AsyncGeneratorFunction%') {
  584. value = getEvalledConstructor('async function* () {}');
  585. } else if (name === '%AsyncGenerator%') {
  586. var fn = doEval('%AsyncGeneratorFunction%');
  587. if (fn) {
  588. value = fn.prototype;
  589. }
  590. } else if (name === '%AsyncIteratorPrototype%') {
  591. var gen = doEval('%AsyncGenerator%');
  592. if (gen && getProto) {
  593. value = getProto(gen.prototype);
  594. }
  595. }
  596. INTRINSICS[name] = value;
  597. return value;
  598. };
  599. var LEGACY_ALIASES = {
  600. __proto__: null,
  601. '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
  602. '%ArrayPrototype%': ['Array', 'prototype'],
  603. '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
  604. '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
  605. '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
  606. '%ArrayProto_values%': ['Array', 'prototype', 'values'],
  607. '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
  608. '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
  609. '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
  610. '%BooleanPrototype%': ['Boolean', 'prototype'],
  611. '%DataViewPrototype%': ['DataView', 'prototype'],
  612. '%DatePrototype%': ['Date', 'prototype'],
  613. '%ErrorPrototype%': ['Error', 'prototype'],
  614. '%EvalErrorPrototype%': ['EvalError', 'prototype'],
  615. '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
  616. '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
  617. '%FunctionPrototype%': ['Function', 'prototype'],
  618. '%Generator%': ['GeneratorFunction', 'prototype'],
  619. '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
  620. '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
  621. '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
  622. '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
  623. '%JSONParse%': ['JSON', 'parse'],
  624. '%JSONStringify%': ['JSON', 'stringify'],
  625. '%MapPrototype%': ['Map', 'prototype'],
  626. '%NumberPrototype%': ['Number', 'prototype'],
  627. '%ObjectPrototype%': ['Object', 'prototype'],
  628. '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
  629. '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
  630. '%PromisePrototype%': ['Promise', 'prototype'],
  631. '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
  632. '%Promise_all%': ['Promise', 'all'],
  633. '%Promise_reject%': ['Promise', 'reject'],
  634. '%Promise_resolve%': ['Promise', 'resolve'],
  635. '%RangeErrorPrototype%': ['RangeError', 'prototype'],
  636. '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
  637. '%RegExpPrototype%': ['RegExp', 'prototype'],
  638. '%SetPrototype%': ['Set', 'prototype'],
  639. '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
  640. '%StringPrototype%': ['String', 'prototype'],
  641. '%SymbolPrototype%': ['Symbol', 'prototype'],
  642. '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
  643. '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
  644. '%TypeErrorPrototype%': ['TypeError', 'prototype'],
  645. '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
  646. '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
  647. '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
  648. '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
  649. '%URIErrorPrototype%': ['URIError', 'prototype'],
  650. '%WeakMapPrototype%': ['WeakMap', 'prototype'],
  651. '%WeakSetPrototype%': ['WeakSet', 'prototype']
  652. };
  653. var bind = require('function-bind');
  654. var hasOwn = require('hasown');
  655. var $concat = bind.call(Function.call, Array.prototype.concat);
  656. var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
  657. var $replace = bind.call(Function.call, String.prototype.replace);
  658. var $strSlice = bind.call(Function.call, String.prototype.slice);
  659. var $exec = bind.call(Function.call, RegExp.prototype.exec);
  660. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  661. var reEscapeChar = /\\(\\)?/g;
  662. var stringToPath = function stringToPath(string) {
  663. var first = $strSlice(string, 0, 1);
  664. var last = $strSlice(string, -1);
  665. if (first === '%' && last !== '%') {
  666. throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
  667. } else if (last === '%' && first !== '%') {
  668. throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
  669. }
  670. var result = [];
  671. $replace(string, rePropName, function (match, number, quote, subString) {
  672. result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
  673. });
  674. return result;
  675. };
  676. var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
  677. var intrinsicName = name;
  678. var alias;
  679. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  680. alias = LEGACY_ALIASES[intrinsicName];
  681. intrinsicName = '%' + alias[0] + '%';
  682. }
  683. if (hasOwn(INTRINSICS, intrinsicName)) {
  684. var value = INTRINSICS[intrinsicName];
  685. if (value === needsEval) {
  686. value = doEval(intrinsicName);
  687. }
  688. if (typeof value === 'undefined' && !allowMissing) {
  689. throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
  690. }
  691. return {
  692. alias: alias,
  693. name: intrinsicName,
  694. value: value
  695. };
  696. }
  697. throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
  698. };
  699. module.exports = function GetIntrinsic(name, allowMissing) {
  700. if (typeof name !== 'string' || name.length === 0) {
  701. throw new $TypeError('intrinsic name must be a non-empty string');
  702. }
  703. if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
  704. throw new $TypeError('"allowMissing" argument must be a boolean');
  705. }
  706. if ($exec(/^%?[^%]*%?$/, name) === null) {
  707. throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
  708. }
  709. var parts = stringToPath(name);
  710. var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
  711. var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
  712. var intrinsicRealName = intrinsic.name;
  713. var value = intrinsic.value;
  714. var skipFurtherCaching = false;
  715. var alias = intrinsic.alias;
  716. if (alias) {
  717. intrinsicBaseName = alias[0];
  718. $spliceApply(parts, $concat([0, 1], alias));
  719. }
  720. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  721. var part = parts[i];
  722. var first = $strSlice(part, 0, 1);
  723. var last = $strSlice(part, -1);
  724. if ((first === '"' || first === "'" || first === '`' || last === '"' || last === "'" || last === '`') && first !== last) {
  725. throw new $SyntaxError('property names with quotes must have matching quotes');
  726. }
  727. if (part === 'constructor' || !isOwn) {
  728. skipFurtherCaching = true;
  729. }
  730. intrinsicBaseName += '.' + part;
  731. intrinsicRealName = '%' + intrinsicBaseName + '%';
  732. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  733. value = INTRINSICS[intrinsicRealName];
  734. } else if (value != null) {
  735. if (!(part in value)) {
  736. if (!allowMissing) {
  737. throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
  738. }
  739. return void undefined;
  740. }
  741. if ($gOPD && i + 1 >= parts.length) {
  742. var desc = $gOPD(value, part);
  743. isOwn = !!desc;
  744. if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
  745. value = desc.get;
  746. } else {
  747. value = value[part];
  748. }
  749. } else {
  750. isOwn = hasOwn(value, part);
  751. value = value[part];
  752. }
  753. if (isOwn && !skipFurtherCaching) {
  754. INTRINSICS[intrinsicRealName] = value;
  755. }
  756. }
  757. }
  758. return value;
  759. };
  760. },{"es-errors":8,"es-errors/eval":7,"es-errors/range":9,"es-errors/ref":10,"es-errors/syntax":11,"es-errors/type":12,"es-errors/uri":13,"function-bind":16,"has-proto":20,"has-symbols":21,"hasown":23}],18:[function(require,module,exports){
  761. 'use strict';
  762. var GetIntrinsic = require('get-intrinsic');
  763. var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
  764. if ($gOPD) {
  765. try {
  766. $gOPD([], 'length');
  767. } catch (e) {
  768. $gOPD = null;
  769. }
  770. }
  771. module.exports = $gOPD;
  772. },{"get-intrinsic":17}],19:[function(require,module,exports){
  773. 'use strict';
  774. var $defineProperty = require('es-define-property');
  775. var hasPropertyDescriptors = function hasPropertyDescriptors() {
  776. return !!$defineProperty;
  777. };
  778. hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
  779. if (!$defineProperty) {
  780. return null;
  781. }
  782. try {
  783. return $defineProperty([], 'length', {
  784. value: 1
  785. }).length !== 1;
  786. } catch (e) {
  787. return true;
  788. }
  789. };
  790. module.exports = hasPropertyDescriptors;
  791. },{"es-define-property":6}],20:[function(require,module,exports){
  792. 'use strict';
  793. var test = {
  794. __proto__: null,
  795. foo: {}
  796. };
  797. var $Object = Object;
  798. module.exports = function hasProto() {
  799. return {
  800. __proto__: test
  801. }.foo === test.foo && !(test instanceof $Object);
  802. };
  803. },{}],21:[function(require,module,exports){
  804. 'use strict';
  805. var origSymbol = typeof Symbol !== 'undefined' && Symbol;
  806. var hasSymbolSham = require('./shams');
  807. module.exports = function hasNativeSymbols() {
  808. if (typeof origSymbol !== 'function') {
  809. return false;
  810. }
  811. if (typeof Symbol !== 'function') {
  812. return false;
  813. }
  814. if (typeof origSymbol('foo') !== 'symbol') {
  815. return false;
  816. }
  817. if (typeof Symbol('bar') !== 'symbol') {
  818. return false;
  819. }
  820. return hasSymbolSham();
  821. };
  822. },{"./shams":22}],22:[function(require,module,exports){
  823. 'use strict';
  824. module.exports = function hasSymbols() {
  825. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
  826. return false;
  827. }
  828. if (typeof Symbol.iterator === 'symbol') {
  829. return true;
  830. }
  831. var obj = {};
  832. var sym = Symbol('test');
  833. var symObj = Object(sym);
  834. if (typeof sym === 'string') {
  835. return false;
  836. }
  837. if (Object.prototype.toString.call(sym) !== '[object Symbol]') {
  838. return false;
  839. }
  840. if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
  841. return false;
  842. }
  843. var symVal = 42;
  844. obj[sym] = symVal;
  845. for (sym in obj) {
  846. return false;
  847. }
  848. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) {
  849. return false;
  850. }
  851. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) {
  852. return false;
  853. }
  854. var syms = Object.getOwnPropertySymbols(obj);
  855. if (syms.length !== 1 || syms[0] !== sym) {
  856. return false;
  857. }
  858. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
  859. return false;
  860. }
  861. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  862. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  863. if (descriptor.value !== symVal || descriptor.enumerable !== true) {
  864. return false;
  865. }
  866. }
  867. return true;
  868. };
  869. },{}],23:[function(require,module,exports){
  870. 'use strict';
  871. var call = Function.prototype.call;
  872. var $hasOwn = Object.prototype.hasOwnProperty;
  873. var bind = require('function-bind');
  874. module.exports = bind.call(call, $hasOwn);
  875. },{"function-bind":16}],24:[function(require,module,exports){
  876. (function (global){(function (){
  877. var hasMap = typeof Map === 'function' && Map.prototype;
  878. var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
  879. var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
  880. var mapForEach = hasMap && Map.prototype.forEach;
  881. var hasSet = typeof Set === 'function' && Set.prototype;
  882. var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
  883. var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
  884. var setForEach = hasSet && Set.prototype.forEach;
  885. var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
  886. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  887. var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
  888. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  889. var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
  890. var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
  891. var booleanValueOf = Boolean.prototype.valueOf;
  892. var objectToString = Object.prototype.toString;
  893. var functionToString = Function.prototype.toString;
  894. var $match = String.prototype.match;
  895. var $slice = String.prototype.slice;
  896. var $replace = String.prototype.replace;
  897. var $toUpperCase = String.prototype.toUpperCase;
  898. var $toLowerCase = String.prototype.toLowerCase;
  899. var $test = RegExp.prototype.test;
  900. var $concat = Array.prototype.concat;
  901. var $join = Array.prototype.join;
  902. var $arrSlice = Array.prototype.slice;
  903. var $floor = Math.floor;
  904. var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
  905. var gOPS = Object.getOwnPropertySymbols;
  906. var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
  907. var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
  908. var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
  909. var isEnumerable = Object.prototype.propertyIsEnumerable;
  910. var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
  911. return O.__proto__;
  912. } : null);
  913. function addNumericSeparator(num, str) {
  914. if (num === Infinity || num === -Infinity || num !== num || num && num > -1000 && num < 1000 || $test.call(/e/, str)) {
  915. return str;
  916. }
  917. var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
  918. if (typeof num === 'number') {
  919. var int = num < 0 ? -$floor(-num) : $floor(num);
  920. if (int !== num) {
  921. var intStr = String(int);
  922. var dec = $slice.call(str, intStr.length + 1);
  923. return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
  924. }
  925. }
  926. return $replace.call(str, sepRegex, '$&_');
  927. }
  928. var utilInspect = require('./util.inspect');
  929. var inspectCustom = utilInspect.custom;
  930. var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
  931. module.exports = function inspect_(obj, options, depth, seen) {
  932. var opts = options || {};
  933. if (has(opts, 'quoteStyle') && opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double') {
  934. throw new TypeError('option "quoteStyle" must be "single" or "double"');
  935. }
  936. if (has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
  937. throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
  938. }
  939. var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
  940. if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
  941. throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
  942. }
  943. if (has(opts, 'indent') && opts.indent !== null && opts.indent !== '\t' && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
  944. throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
  945. }
  946. if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
  947. throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
  948. }
  949. var numericSeparator = opts.numericSeparator;
  950. if (typeof obj === 'undefined') {
  951. return 'undefined';
  952. }
  953. if (obj === null) {
  954. return 'null';
  955. }
  956. if (typeof obj === 'boolean') {
  957. return obj ? 'true' : 'false';
  958. }
  959. if (typeof obj === 'string') {
  960. return inspectString(obj, opts);
  961. }
  962. if (typeof obj === 'number') {
  963. if (obj === 0) {
  964. return Infinity / obj > 0 ? '0' : '-0';
  965. }
  966. var str = String(obj);
  967. return numericSeparator ? addNumericSeparator(obj, str) : str;
  968. }
  969. if (typeof obj === 'bigint') {
  970. var bigIntStr = String(obj) + 'n';
  971. return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
  972. }
  973. var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
  974. if (typeof depth === 'undefined') {
  975. depth = 0;
  976. }
  977. if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
  978. return isArray(obj) ? '[Array]' : '[Object]';
  979. }
  980. var indent = getIndent(opts, depth);
  981. if (typeof seen === 'undefined') {
  982. seen = [];
  983. } else if (indexOf(seen, obj) >= 0) {
  984. return '[Circular]';
  985. }
  986. function inspect(value, from, noIndent) {
  987. if (from) {
  988. seen = $arrSlice.call(seen);
  989. seen.push(from);
  990. }
  991. if (noIndent) {
  992. var newOpts = {
  993. depth: opts.depth
  994. };
  995. if (has(opts, 'quoteStyle')) {
  996. newOpts.quoteStyle = opts.quoteStyle;
  997. }
  998. return inspect_(value, newOpts, depth + 1, seen);
  999. }
  1000. return inspect_(value, opts, depth + 1, seen);
  1001. }
  1002. if (typeof obj === 'function' && !isRegExp(obj)) {
  1003. var name = nameOf(obj);
  1004. var keys = arrObjKeys(obj, inspect);
  1005. return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
  1006. }
  1007. if (isSymbol(obj)) {
  1008. var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
  1009. return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
  1010. }
  1011. if (isElement(obj)) {
  1012. var s = '<' + $toLowerCase.call(String(obj.nodeName));
  1013. var attrs = obj.attributes || [];
  1014. for (var i = 0; i < attrs.length; i++) {
  1015. s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
  1016. }
  1017. s += '>';
  1018. if (obj.childNodes && obj.childNodes.length) {
  1019. s += '...';
  1020. }
  1021. s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
  1022. return s;
  1023. }
  1024. if (isArray(obj)) {
  1025. if (obj.length === 0) {
  1026. return '[]';
  1027. }
  1028. var xs = arrObjKeys(obj, inspect);
  1029. if (indent && !singleLineValues(xs)) {
  1030. return '[' + indentedJoin(xs, indent) + ']';
  1031. }
  1032. return '[ ' + $join.call(xs, ', ') + ' ]';
  1033. }
  1034. if (isError(obj)) {
  1035. var parts = arrObjKeys(obj, inspect);
  1036. if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
  1037. return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
  1038. }
  1039. if (parts.length === 0) {
  1040. return '[' + String(obj) + ']';
  1041. }
  1042. return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
  1043. }
  1044. if (typeof obj === 'object' && customInspect) {
  1045. if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
  1046. return utilInspect(obj, {
  1047. depth: maxDepth - depth
  1048. });
  1049. } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
  1050. return obj.inspect();
  1051. }
  1052. }
  1053. if (isMap(obj)) {
  1054. var mapParts = [];
  1055. if (mapForEach) {
  1056. mapForEach.call(obj, function (value, key) {
  1057. mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
  1058. });
  1059. }
  1060. return collectionOf('Map', mapSize.call(obj), mapParts, indent);
  1061. }
  1062. if (isSet(obj)) {
  1063. var setParts = [];
  1064. if (setForEach) {
  1065. setForEach.call(obj, function (value) {
  1066. setParts.push(inspect(value, obj));
  1067. });
  1068. }
  1069. return collectionOf('Set', setSize.call(obj), setParts, indent);
  1070. }
  1071. if (isWeakMap(obj)) {
  1072. return weakCollectionOf('WeakMap');
  1073. }
  1074. if (isWeakSet(obj)) {
  1075. return weakCollectionOf('WeakSet');
  1076. }
  1077. if (isWeakRef(obj)) {
  1078. return weakCollectionOf('WeakRef');
  1079. }
  1080. if (isNumber(obj)) {
  1081. return markBoxed(inspect(Number(obj)));
  1082. }
  1083. if (isBigInt(obj)) {
  1084. return markBoxed(inspect(bigIntValueOf.call(obj)));
  1085. }
  1086. if (isBoolean(obj)) {
  1087. return markBoxed(booleanValueOf.call(obj));
  1088. }
  1089. if (isString(obj)) {
  1090. return markBoxed(inspect(String(obj)));
  1091. }
  1092. if (typeof window !== 'undefined' && obj === window) {
  1093. return '{ [object Window] }';
  1094. }
  1095. if (obj === global) {
  1096. return '{ [object globalThis] }';
  1097. }
  1098. if (!isDate(obj) && !isRegExp(obj)) {
  1099. var ys = arrObjKeys(obj, inspect);
  1100. var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
  1101. var protoTag = obj instanceof Object ? '' : 'null prototype';
  1102. var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
  1103. var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
  1104. var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
  1105. if (ys.length === 0) {
  1106. return tag + '{}';
  1107. }
  1108. if (indent) {
  1109. return tag + '{' + indentedJoin(ys, indent) + '}';
  1110. }
  1111. return tag + '{ ' + $join.call(ys, ', ') + ' }';
  1112. }
  1113. return String(obj);
  1114. };
  1115. function wrapQuotes(s, defaultStyle, opts) {
  1116. var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
  1117. return quoteChar + s + quoteChar;
  1118. }
  1119. function quote(s) {
  1120. return $replace.call(String(s), /"/g, '&quot;');
  1121. }
  1122. function isArray(obj) {
  1123. return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1124. }
  1125. function isDate(obj) {
  1126. return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1127. }
  1128. function isRegExp(obj) {
  1129. return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1130. }
  1131. function isError(obj) {
  1132. return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1133. }
  1134. function isString(obj) {
  1135. return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1136. }
  1137. function isNumber(obj) {
  1138. return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1139. }
  1140. function isBoolean(obj) {
  1141. return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj));
  1142. }
  1143. function isSymbol(obj) {
  1144. if (hasShammedSymbols) {
  1145. return obj && typeof obj === 'object' && obj instanceof Symbol;
  1146. }
  1147. if (typeof obj === 'symbol') {
  1148. return true;
  1149. }
  1150. if (!obj || typeof obj !== 'object' || !symToString) {
  1151. return false;
  1152. }
  1153. try {
  1154. symToString.call(obj);
  1155. return true;
  1156. } catch (e) {}
  1157. return false;
  1158. }
  1159. function isBigInt(obj) {
  1160. if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
  1161. return false;
  1162. }
  1163. try {
  1164. bigIntValueOf.call(obj);
  1165. return true;
  1166. } catch (e) {}
  1167. return false;
  1168. }
  1169. var hasOwn = Object.prototype.hasOwnProperty || function (key) {
  1170. return key in this;
  1171. };
  1172. function has(obj, key) {
  1173. return hasOwn.call(obj, key);
  1174. }
  1175. function toStr(obj) {
  1176. return objectToString.call(obj);
  1177. }
  1178. function nameOf(f) {
  1179. if (f.name) {
  1180. return f.name;
  1181. }
  1182. var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
  1183. if (m) {
  1184. return m[1];
  1185. }
  1186. return null;
  1187. }
  1188. function indexOf(xs, x) {
  1189. if (xs.indexOf) {
  1190. return xs.indexOf(x);
  1191. }
  1192. for (var i = 0, l = xs.length; i < l; i++) {
  1193. if (xs[i] === x) {
  1194. return i;
  1195. }
  1196. }
  1197. return -1;
  1198. }
  1199. function isMap(x) {
  1200. if (!mapSize || !x || typeof x !== 'object') {
  1201. return false;
  1202. }
  1203. try {
  1204. mapSize.call(x);
  1205. try {
  1206. setSize.call(x);
  1207. } catch (s) {
  1208. return true;
  1209. }
  1210. return x instanceof Map;
  1211. } catch (e) {}
  1212. return false;
  1213. }
  1214. function isWeakMap(x) {
  1215. if (!weakMapHas || !x || typeof x !== 'object') {
  1216. return false;
  1217. }
  1218. try {
  1219. weakMapHas.call(x, weakMapHas);
  1220. try {
  1221. weakSetHas.call(x, weakSetHas);
  1222. } catch (s) {
  1223. return true;
  1224. }
  1225. return x instanceof WeakMap;
  1226. } catch (e) {}
  1227. return false;
  1228. }
  1229. function isWeakRef(x) {
  1230. if (!weakRefDeref || !x || typeof x !== 'object') {
  1231. return false;
  1232. }
  1233. try {
  1234. weakRefDeref.call(x);
  1235. return true;
  1236. } catch (e) {}
  1237. return false;
  1238. }
  1239. function isSet(x) {
  1240. if (!setSize || !x || typeof x !== 'object') {
  1241. return false;
  1242. }
  1243. try {
  1244. setSize.call(x);
  1245. try {
  1246. mapSize.call(x);
  1247. } catch (m) {
  1248. return true;
  1249. }
  1250. return x instanceof Set;
  1251. } catch (e) {}
  1252. return false;
  1253. }
  1254. function isWeakSet(x) {
  1255. if (!weakSetHas || !x || typeof x !== 'object') {
  1256. return false;
  1257. }
  1258. try {
  1259. weakSetHas.call(x, weakSetHas);
  1260. try {
  1261. weakMapHas.call(x, weakMapHas);
  1262. } catch (s) {
  1263. return true;
  1264. }
  1265. return x instanceof WeakSet;
  1266. } catch (e) {}
  1267. return false;
  1268. }
  1269. function isElement(x) {
  1270. if (!x || typeof x !== 'object') {
  1271. return false;
  1272. }
  1273. if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
  1274. return true;
  1275. }
  1276. return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
  1277. }
  1278. function inspectString(str, opts) {
  1279. if (str.length > opts.maxStringLength) {
  1280. var remaining = str.length - opts.maxStringLength;
  1281. var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
  1282. return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
  1283. }
  1284. var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
  1285. return wrapQuotes(s, 'single', opts);
  1286. }
  1287. function lowbyte(c) {
  1288. var n = c.charCodeAt(0);
  1289. var x = {
  1290. 8: 'b',
  1291. 9: 't',
  1292. 10: 'n',
  1293. 12: 'f',
  1294. 13: 'r'
  1295. }[n];
  1296. if (x) {
  1297. return '\\' + x;
  1298. }
  1299. return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
  1300. }
  1301. function markBoxed(str) {
  1302. return 'Object(' + str + ')';
  1303. }
  1304. function weakCollectionOf(type) {
  1305. return type + ' { ? }';
  1306. }
  1307. function collectionOf(type, size, entries, indent) {
  1308. var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
  1309. return type + ' (' + size + ') {' + joinedEntries + '}';
  1310. }
  1311. function singleLineValues(xs) {
  1312. for (var i = 0; i < xs.length; i++) {
  1313. if (indexOf(xs[i], '\n') >= 0) {
  1314. return false;
  1315. }
  1316. }
  1317. return true;
  1318. }
  1319. function getIndent(opts, depth) {
  1320. var baseIndent;
  1321. if (opts.indent === '\t') {
  1322. baseIndent = '\t';
  1323. } else if (typeof opts.indent === 'number' && opts.indent > 0) {
  1324. baseIndent = $join.call(Array(opts.indent + 1), ' ');
  1325. } else {
  1326. return null;
  1327. }
  1328. return {
  1329. base: baseIndent,
  1330. prev: $join.call(Array(depth + 1), baseIndent)
  1331. };
  1332. }
  1333. function indentedJoin(xs, indent) {
  1334. if (xs.length === 0) {
  1335. return '';
  1336. }
  1337. var lineJoiner = '\n' + indent.prev + indent.base;
  1338. return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
  1339. }
  1340. function arrObjKeys(obj, inspect) {
  1341. var isArr = isArray(obj);
  1342. var xs = [];
  1343. if (isArr) {
  1344. xs.length = obj.length;
  1345. for (var i = 0; i < obj.length; i++) {
  1346. xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
  1347. }
  1348. }
  1349. var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
  1350. var symMap;
  1351. if (hasShammedSymbols) {
  1352. symMap = {};
  1353. for (var k = 0; k < syms.length; k++) {
  1354. symMap['$' + syms[k]] = syms[k];
  1355. }
  1356. }
  1357. for (var key in obj) {
  1358. if (!has(obj, key)) {
  1359. continue;
  1360. }
  1361. if (isArr && String(Number(key)) === key && key < obj.length) {
  1362. continue;
  1363. }
  1364. if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
  1365. continue;
  1366. } else if ($test.call(/[^\w$]/, key)) {
  1367. xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
  1368. } else {
  1369. xs.push(key + ': ' + inspect(obj[key], obj));
  1370. }
  1371. }
  1372. if (typeof gOPS === 'function') {
  1373. for (var j = 0; j < syms.length; j++) {
  1374. if (isEnumerable.call(obj, syms[j])) {
  1375. xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
  1376. }
  1377. }
  1378. }
  1379. return xs;
  1380. }
  1381. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1382. },{"./util.inspect":1}],25:[function(require,module,exports){
  1383. var process = module.exports = {};
  1384. var cachedSetTimeout;
  1385. var cachedClearTimeout;
  1386. function defaultSetTimout() {
  1387. throw new Error('setTimeout has not been defined');
  1388. }
  1389. function defaultClearTimeout() {
  1390. throw new Error('clearTimeout has not been defined');
  1391. }
  1392. (function () {
  1393. try {
  1394. if (typeof setTimeout === 'function') {
  1395. cachedSetTimeout = setTimeout;
  1396. } else {
  1397. cachedSetTimeout = defaultSetTimout;
  1398. }
  1399. } catch (e) {
  1400. cachedSetTimeout = defaultSetTimout;
  1401. }
  1402. try {
  1403. if (typeof clearTimeout === 'function') {
  1404. cachedClearTimeout = clearTimeout;
  1405. } else {
  1406. cachedClearTimeout = defaultClearTimeout;
  1407. }
  1408. } catch (e) {
  1409. cachedClearTimeout = defaultClearTimeout;
  1410. }
  1411. })();
  1412. function runTimeout(fun) {
  1413. if (cachedSetTimeout === setTimeout) {
  1414. return setTimeout(fun, 0);
  1415. }
  1416. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1417. cachedSetTimeout = setTimeout;
  1418. return setTimeout(fun, 0);
  1419. }
  1420. try {
  1421. return cachedSetTimeout(fun, 0);
  1422. } catch (e) {
  1423. try {
  1424. return cachedSetTimeout.call(null, fun, 0);
  1425. } catch (e) {
  1426. return cachedSetTimeout.call(this, fun, 0);
  1427. }
  1428. }
  1429. }
  1430. function runClearTimeout(marker) {
  1431. if (cachedClearTimeout === clearTimeout) {
  1432. return clearTimeout(marker);
  1433. }
  1434. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1435. cachedClearTimeout = clearTimeout;
  1436. return clearTimeout(marker);
  1437. }
  1438. try {
  1439. return cachedClearTimeout(marker);
  1440. } catch (e) {
  1441. try {
  1442. return cachedClearTimeout.call(null, marker);
  1443. } catch (e) {
  1444. return cachedClearTimeout.call(this, marker);
  1445. }
  1446. }
  1447. }
  1448. var queue = [];
  1449. var draining = false;
  1450. var currentQueue;
  1451. var queueIndex = -1;
  1452. function cleanUpNextTick() {
  1453. if (!draining || !currentQueue) {
  1454. return;
  1455. }
  1456. draining = false;
  1457. if (currentQueue.length) {
  1458. queue = currentQueue.concat(queue);
  1459. } else {
  1460. queueIndex = -1;
  1461. }
  1462. if (queue.length) {
  1463. drainQueue();
  1464. }
  1465. }
  1466. function drainQueue() {
  1467. if (draining) {
  1468. return;
  1469. }
  1470. var timeout = runTimeout(cleanUpNextTick);
  1471. draining = true;
  1472. var len = queue.length;
  1473. while (len) {
  1474. currentQueue = queue;
  1475. queue = [];
  1476. while (++queueIndex < len) {
  1477. if (currentQueue) {
  1478. currentQueue[queueIndex].run();
  1479. }
  1480. }
  1481. queueIndex = -1;
  1482. len = queue.length;
  1483. }
  1484. currentQueue = null;
  1485. draining = false;
  1486. runClearTimeout(timeout);
  1487. }
  1488. process.nextTick = function (fun) {
  1489. var args = new Array(arguments.length - 1);
  1490. if (arguments.length > 1) {
  1491. for (var i = 1; i < arguments.length; i++) {
  1492. args[i - 1] = arguments[i];
  1493. }
  1494. }
  1495. queue.push(new Item(fun, args));
  1496. if (queue.length === 1 && !draining) {
  1497. runTimeout(drainQueue);
  1498. }
  1499. };
  1500. function Item(fun, array) {
  1501. this.fun = fun;
  1502. this.array = array;
  1503. }
  1504. Item.prototype.run = function () {
  1505. this.fun.apply(null, this.array);
  1506. };
  1507. process.title = 'browser';
  1508. process.browser = true;
  1509. process.env = {};
  1510. process.argv = [];
  1511. process.version = '';
  1512. process.versions = {};
  1513. function noop() {}
  1514. process.on = noop;
  1515. process.addListener = noop;
  1516. process.once = noop;
  1517. process.off = noop;
  1518. process.removeListener = noop;
  1519. process.removeAllListeners = noop;
  1520. process.emit = noop;
  1521. process.prependListener = noop;
  1522. process.prependOnceListener = noop;
  1523. process.listeners = function (name) {
  1524. return [];
  1525. };
  1526. process.binding = function (name) {
  1527. throw new Error('process.binding is not supported');
  1528. };
  1529. process.cwd = function () {
  1530. return '/';
  1531. };
  1532. process.chdir = function (dir) {
  1533. throw new Error('process.chdir is not supported');
  1534. };
  1535. process.umask = function () {
  1536. return 0;
  1537. };
  1538. },{}],26:[function(require,module,exports){
  1539. 'use strict';
  1540. var replace = String.prototype.replace;
  1541. var percentTwenties = /%20/g;
  1542. var Format = {
  1543. RFC1738: 'RFC1738',
  1544. RFC3986: 'RFC3986'
  1545. };
  1546. module.exports = {
  1547. 'default': Format.RFC3986,
  1548. formatters: {
  1549. RFC1738: function (value) {
  1550. return replace.call(value, percentTwenties, '+');
  1551. },
  1552. RFC3986: function (value) {
  1553. return String(value);
  1554. }
  1555. },
  1556. RFC1738: Format.RFC1738,
  1557. RFC3986: Format.RFC3986
  1558. };
  1559. },{}],27:[function(require,module,exports){
  1560. 'use strict';
  1561. var stringify = require('./stringify');
  1562. var parse = require('./parse');
  1563. var formats = require('./formats');
  1564. module.exports = {
  1565. formats: formats,
  1566. parse: parse,
  1567. stringify: stringify
  1568. };
  1569. },{"./formats":26,"./parse":28,"./stringify":29}],28:[function(require,module,exports){
  1570. 'use strict';
  1571. var utils = require('./utils');
  1572. var has = Object.prototype.hasOwnProperty;
  1573. var isArray = Array.isArray;
  1574. var defaults = {
  1575. allowDots: false,
  1576. allowEmptyArrays: false,
  1577. allowPrototypes: false,
  1578. allowSparse: false,
  1579. arrayLimit: 20,
  1580. charset: 'utf-8',
  1581. charsetSentinel: false,
  1582. comma: false,
  1583. decodeDotInKeys: false,
  1584. decoder: utils.decode,
  1585. delimiter: '&',
  1586. depth: 5,
  1587. duplicates: 'combine',
  1588. ignoreQueryPrefix: false,
  1589. interpretNumericEntities: false,
  1590. parameterLimit: 1000,
  1591. parseArrays: true,
  1592. plainObjects: false,
  1593. strictNullHandling: false
  1594. };
  1595. var interpretNumericEntities = function (str) {
  1596. return str.replace(/&#(\d+);/g, function ($0, numberStr) {
  1597. return String.fromCharCode(parseInt(numberStr, 10));
  1598. });
  1599. };
  1600. var parseArrayValue = function (val, options) {
  1601. if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
  1602. return val.split(',');
  1603. }
  1604. return val;
  1605. };
  1606. var isoSentinel = 'utf8=%26%2310003%3B';
  1607. var charsetSentinel = 'utf8=%E2%9C%93';
  1608. var parseValues = function parseQueryStringValues(str, options) {
  1609. var obj = {
  1610. __proto__: null
  1611. };
  1612. var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
  1613. var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
  1614. var parts = cleanStr.split(options.delimiter, limit);
  1615. var skipIndex = -1;
  1616. var i;
  1617. var charset = options.charset;
  1618. if (options.charsetSentinel) {
  1619. for (i = 0; i < parts.length; ++i) {
  1620. if (parts[i].indexOf('utf8=') === 0) {
  1621. if (parts[i] === charsetSentinel) {
  1622. charset = 'utf-8';
  1623. } else if (parts[i] === isoSentinel) {
  1624. charset = 'iso-8859-1';
  1625. }
  1626. skipIndex = i;
  1627. i = parts.length;
  1628. }
  1629. }
  1630. }
  1631. for (i = 0; i < parts.length; ++i) {
  1632. if (i === skipIndex) {
  1633. continue;
  1634. }
  1635. var part = parts[i];
  1636. var bracketEqualsPos = part.indexOf(']=');
  1637. var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
  1638. var key, val;
  1639. if (pos === -1) {
  1640. key = options.decoder(part, defaults.decoder, charset, 'key');
  1641. val = options.strictNullHandling ? null : '';
  1642. } else {
  1643. key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
  1644. val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function (encodedVal) {
  1645. return options.decoder(encodedVal, defaults.decoder, charset, 'value');
  1646. });
  1647. }
  1648. if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
  1649. val = interpretNumericEntities(val);
  1650. }
  1651. if (part.indexOf('[]=') > -1) {
  1652. val = isArray(val) ? [val] : val;
  1653. }
  1654. var existing = has.call(obj, key);
  1655. if (existing && options.duplicates === 'combine') {
  1656. obj[key] = utils.combine(obj[key], val);
  1657. } else if (!existing || options.duplicates === 'last') {
  1658. obj[key] = val;
  1659. }
  1660. }
  1661. return obj;
  1662. };
  1663. var parseObject = function (chain, val, options, valuesParsed) {
  1664. var leaf = valuesParsed ? val : parseArrayValue(val, options);
  1665. for (var i = chain.length - 1; i >= 0; --i) {
  1666. var obj;
  1667. var root = chain[i];
  1668. if (root === '[]' && options.parseArrays) {
  1669. obj = options.allowEmptyArrays && leaf === '' ? [] : [].concat(leaf);
  1670. } else {
  1671. obj = options.plainObjects ? Object.create(null) : {};
  1672. var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
  1673. var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot;
  1674. var index = parseInt(decodedRoot, 10);
  1675. if (!options.parseArrays && decodedRoot === '') {
  1676. obj = {
  1677. 0: leaf
  1678. };
  1679. } else if (!isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
  1680. obj = [];
  1681. obj[index] = leaf;
  1682. } else if (decodedRoot !== '__proto__') {
  1683. obj[decodedRoot] = leaf;
  1684. }
  1685. }
  1686. leaf = obj;
  1687. }
  1688. return leaf;
  1689. };
  1690. var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
  1691. if (!givenKey) {
  1692. return;
  1693. }
  1694. var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
  1695. var brackets = /(\[[^[\]]*])/;
  1696. var child = /(\[[^[\]]*])/g;
  1697. var segment = options.depth > 0 && brackets.exec(key);
  1698. var parent = segment ? key.slice(0, segment.index) : key;
  1699. var keys = [];
  1700. if (parent) {
  1701. if (!options.plainObjects && has.call(Object.prototype, parent)) {
  1702. if (!options.allowPrototypes) {
  1703. return;
  1704. }
  1705. }
  1706. keys.push(parent);
  1707. }
  1708. var i = 0;
  1709. while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
  1710. i += 1;
  1711. if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
  1712. if (!options.allowPrototypes) {
  1713. return;
  1714. }
  1715. }
  1716. keys.push(segment[1]);
  1717. }
  1718. if (segment) {
  1719. keys.push('[' + key.slice(segment.index) + ']');
  1720. }
  1721. return parseObject(keys, val, options, valuesParsed);
  1722. };
  1723. var normalizeParseOptions = function normalizeParseOptions(opts) {
  1724. if (!opts) {
  1725. return defaults;
  1726. }
  1727. if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
  1728. throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
  1729. }
  1730. if (typeof opts.decodeDotInKeys !== 'undefined' && typeof opts.decodeDotInKeys !== 'boolean') {
  1731. throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided');
  1732. }
  1733. if (opts.decoder !== null && typeof opts.decoder !== 'undefined' && typeof opts.decoder !== 'function') {
  1734. throw new TypeError('Decoder has to be a function.');
  1735. }
  1736. if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
  1737. throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
  1738. }
  1739. var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
  1740. var duplicates = typeof opts.duplicates === 'undefined' ? defaults.duplicates : opts.duplicates;
  1741. if (duplicates !== 'combine' && duplicates !== 'first' && duplicates !== 'last') {
  1742. throw new TypeError('The duplicates option must be either combine, first, or last');
  1743. }
  1744. var allowDots = typeof opts.allowDots === 'undefined' ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  1745. return {
  1746. allowDots: allowDots,
  1747. allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  1748. allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
  1749. allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
  1750. arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
  1751. charset: charset,
  1752. charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
  1753. comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
  1754. decodeDotInKeys: typeof opts.decodeDotInKeys === 'boolean' ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
  1755. decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
  1756. delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
  1757. depth: typeof opts.depth === 'number' || opts.depth === false ? +opts.depth : defaults.depth,
  1758. duplicates: duplicates,
  1759. ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
  1760. interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
  1761. parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
  1762. parseArrays: opts.parseArrays !== false,
  1763. plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
  1764. strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
  1765. };
  1766. };
  1767. module.exports = function (str, opts) {
  1768. var options = normalizeParseOptions(opts);
  1769. if (str === '' || str === null || typeof str === 'undefined') {
  1770. return options.plainObjects ? Object.create(null) : {};
  1771. }
  1772. var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
  1773. var obj = options.plainObjects ? Object.create(null) : {};
  1774. var keys = Object.keys(tempObj);
  1775. for (var i = 0; i < keys.length; ++i) {
  1776. var key = keys[i];
  1777. var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
  1778. obj = utils.merge(obj, newObj, options);
  1779. }
  1780. if (options.allowSparse === true) {
  1781. return obj;
  1782. }
  1783. return utils.compact(obj);
  1784. };
  1785. },{"./utils":30}],29:[function(require,module,exports){
  1786. 'use strict';
  1787. var getSideChannel = require('side-channel');
  1788. var utils = require('./utils');
  1789. var formats = require('./formats');
  1790. var has = Object.prototype.hasOwnProperty;
  1791. var arrayPrefixGenerators = {
  1792. brackets: function brackets(prefix) {
  1793. return prefix + '[]';
  1794. },
  1795. comma: 'comma',
  1796. indices: function indices(prefix, key) {
  1797. return prefix + '[' + key + ']';
  1798. },
  1799. repeat: function repeat(prefix) {
  1800. return prefix;
  1801. }
  1802. };
  1803. var isArray = Array.isArray;
  1804. var push = Array.prototype.push;
  1805. var pushToArray = function (arr, valueOrArray) {
  1806. push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
  1807. };
  1808. var toISO = Date.prototype.toISOString;
  1809. var defaultFormat = formats['default'];
  1810. var defaults = {
  1811. addQueryPrefix: false,
  1812. allowDots: false,
  1813. allowEmptyArrays: false,
  1814. arrayFormat: 'indices',
  1815. charset: 'utf-8',
  1816. charsetSentinel: false,
  1817. delimiter: '&',
  1818. encode: true,
  1819. encodeDotInKeys: false,
  1820. encoder: utils.encode,
  1821. encodeValuesOnly: false,
  1822. format: defaultFormat,
  1823. formatter: formats.formatters[defaultFormat],
  1824. indices: false,
  1825. serializeDate: function serializeDate(date) {
  1826. return toISO.call(date);
  1827. },
  1828. skipNulls: false,
  1829. strictNullHandling: false
  1830. };
  1831. var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
  1832. return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'symbol' || typeof v === 'bigint';
  1833. };
  1834. var sentinel = {};
  1835. var stringify = function stringify(object, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
  1836. var obj = object;
  1837. var tmpSc = sideChannel;
  1838. var step = 0;
  1839. var findFlag = false;
  1840. while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
  1841. var pos = tmpSc.get(object);
  1842. step += 1;
  1843. if (typeof pos !== 'undefined') {
  1844. if (pos === step) {
  1845. throw new RangeError('Cyclic object value');
  1846. } else {
  1847. findFlag = true;
  1848. }
  1849. }
  1850. if (typeof tmpSc.get(sentinel) === 'undefined') {
  1851. step = 0;
  1852. }
  1853. }
  1854. if (typeof filter === 'function') {
  1855. obj = filter(prefix, obj);
  1856. } else if (obj instanceof Date) {
  1857. obj = serializeDate(obj);
  1858. } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
  1859. obj = utils.maybeMap(obj, function (value) {
  1860. if (value instanceof Date) {
  1861. return serializeDate(value);
  1862. }
  1863. return value;
  1864. });
  1865. }
  1866. if (obj === null) {
  1867. if (strictNullHandling) {
  1868. return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
  1869. }
  1870. obj = '';
  1871. }
  1872. if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
  1873. if (encoder) {
  1874. var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
  1875. return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
  1876. }
  1877. return [formatter(prefix) + '=' + formatter(String(obj))];
  1878. }
  1879. var values = [];
  1880. if (typeof obj === 'undefined') {
  1881. return values;
  1882. }
  1883. var objKeys;
  1884. if (generateArrayPrefix === 'comma' && isArray(obj)) {
  1885. if (encodeValuesOnly && encoder) {
  1886. obj = utils.maybeMap(obj, encoder);
  1887. }
  1888. objKeys = [{
  1889. value: obj.length > 0 ? obj.join(',') || null : void undefined
  1890. }];
  1891. } else if (isArray(filter)) {
  1892. objKeys = filter;
  1893. } else {
  1894. var keys = Object.keys(obj);
  1895. objKeys = sort ? keys.sort(sort) : keys;
  1896. }
  1897. var encodedPrefix = encodeDotInKeys ? prefix.replace(/\./g, '%2E') : prefix;
  1898. var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix;
  1899. if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
  1900. return adjustedPrefix + '[]';
  1901. }
  1902. for (var j = 0; j < objKeys.length; ++j) {
  1903. var key = objKeys[j];
  1904. var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
  1905. if (skipNulls && value === null) {
  1906. continue;
  1907. }
  1908. var encodedKey = allowDots && encodeDotInKeys ? key.replace(/\./g, '%2E') : key;
  1909. var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix : adjustedPrefix + (allowDots ? '.' + encodedKey : '[' + encodedKey + ']');
  1910. sideChannel.set(object, step);
  1911. var valueSideChannel = getSideChannel();
  1912. valueSideChannel.set(sentinel, sideChannel);
  1913. pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
  1914. }
  1915. return values;
  1916. };
  1917. var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
  1918. if (!opts) {
  1919. return defaults;
  1920. }
  1921. if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
  1922. throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
  1923. }
  1924. if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
  1925. throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');
  1926. }
  1927. if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
  1928. throw new TypeError('Encoder has to be a function.');
  1929. }
  1930. var charset = opts.charset || defaults.charset;
  1931. if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
  1932. throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
  1933. }
  1934. var format = formats['default'];
  1935. if (typeof opts.format !== 'undefined') {
  1936. if (!has.call(formats.formatters, opts.format)) {
  1937. throw new TypeError('Unknown format option provided.');
  1938. }
  1939. format = opts.format;
  1940. }
  1941. var formatter = formats.formatters[format];
  1942. var filter = defaults.filter;
  1943. if (typeof opts.filter === 'function' || isArray(opts.filter)) {
  1944. filter = opts.filter;
  1945. }
  1946. var arrayFormat;
  1947. if (opts.arrayFormat in arrayPrefixGenerators) {
  1948. arrayFormat = opts.arrayFormat;
  1949. } else if ('indices' in opts) {
  1950. arrayFormat = opts.indices ? 'indices' : 'repeat';
  1951. } else {
  1952. arrayFormat = defaults.arrayFormat;
  1953. }
  1954. if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
  1955. throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
  1956. }
  1957. var allowDots = typeof opts.allowDots === 'undefined' ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  1958. return {
  1959. addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
  1960. allowDots: allowDots,
  1961. allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  1962. arrayFormat: arrayFormat,
  1963. charset: charset,
  1964. charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
  1965. commaRoundTrip: opts.commaRoundTrip,
  1966. delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
  1967. encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
  1968. encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
  1969. encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
  1970. encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
  1971. filter: filter,
  1972. format: format,
  1973. formatter: formatter,
  1974. serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
  1975. skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
  1976. sort: typeof opts.sort === 'function' ? opts.sort : null,
  1977. strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
  1978. };
  1979. };
  1980. module.exports = function (object, opts) {
  1981. var obj = object;
  1982. var options = normalizeStringifyOptions(opts);
  1983. var objKeys;
  1984. var filter;
  1985. if (typeof options.filter === 'function') {
  1986. filter = options.filter;
  1987. obj = filter('', obj);
  1988. } else if (isArray(options.filter)) {
  1989. filter = options.filter;
  1990. objKeys = filter;
  1991. }
  1992. var keys = [];
  1993. if (typeof obj !== 'object' || obj === null) {
  1994. return '';
  1995. }
  1996. var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
  1997. var commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip;
  1998. if (!objKeys) {
  1999. objKeys = Object.keys(obj);
  2000. }
  2001. if (options.sort) {
  2002. objKeys.sort(options.sort);
  2003. }
  2004. var sideChannel = getSideChannel();
  2005. for (var i = 0; i < objKeys.length; ++i) {
  2006. var key = objKeys[i];
  2007. if (options.skipNulls && obj[key] === null) {
  2008. continue;
  2009. }
  2010. pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, commaRoundTrip, options.allowEmptyArrays, options.strictNullHandling, options.skipNulls, options.encodeDotInKeys, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
  2011. }
  2012. var joined = keys.join(options.delimiter);
  2013. var prefix = options.addQueryPrefix === true ? '?' : '';
  2014. if (options.charsetSentinel) {
  2015. if (options.charset === 'iso-8859-1') {
  2016. prefix += 'utf8=%26%2310003%3B&';
  2017. } else {
  2018. prefix += 'utf8=%E2%9C%93&';
  2019. }
  2020. }
  2021. return joined.length > 0 ? prefix + joined : '';
  2022. };
  2023. },{"./formats":26,"./utils":30,"side-channel":32}],30:[function(require,module,exports){
  2024. 'use strict';
  2025. var formats = require('./formats');
  2026. var has = Object.prototype.hasOwnProperty;
  2027. var isArray = Array.isArray;
  2028. var hexTable = function () {
  2029. var array = [];
  2030. for (var i = 0; i < 256; ++i) {
  2031. array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
  2032. }
  2033. return array;
  2034. }();
  2035. var compactQueue = function compactQueue(queue) {
  2036. while (queue.length > 1) {
  2037. var item = queue.pop();
  2038. var obj = item.obj[item.prop];
  2039. if (isArray(obj)) {
  2040. var compacted = [];
  2041. for (var j = 0; j < obj.length; ++j) {
  2042. if (typeof obj[j] !== 'undefined') {
  2043. compacted.push(obj[j]);
  2044. }
  2045. }
  2046. item.obj[item.prop] = compacted;
  2047. }
  2048. }
  2049. };
  2050. var arrayToObject = function arrayToObject(source, options) {
  2051. var obj = options && options.plainObjects ? Object.create(null) : {};
  2052. for (var i = 0; i < source.length; ++i) {
  2053. if (typeof source[i] !== 'undefined') {
  2054. obj[i] = source[i];
  2055. }
  2056. }
  2057. return obj;
  2058. };
  2059. var merge = function merge(target, source, options) {
  2060. if (!source) {
  2061. return target;
  2062. }
  2063. if (typeof source !== 'object') {
  2064. if (isArray(target)) {
  2065. target.push(source);
  2066. } else if (target && typeof target === 'object') {
  2067. if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
  2068. target[source] = true;
  2069. }
  2070. } else {
  2071. return [target, source];
  2072. }
  2073. return target;
  2074. }
  2075. if (!target || typeof target !== 'object') {
  2076. return [target].concat(source);
  2077. }
  2078. var mergeTarget = target;
  2079. if (isArray(target) && !isArray(source)) {
  2080. mergeTarget = arrayToObject(target, options);
  2081. }
  2082. if (isArray(target) && isArray(source)) {
  2083. source.forEach(function (item, i) {
  2084. if (has.call(target, i)) {
  2085. var targetItem = target[i];
  2086. if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
  2087. target[i] = merge(targetItem, item, options);
  2088. } else {
  2089. target.push(item);
  2090. }
  2091. } else {
  2092. target[i] = item;
  2093. }
  2094. });
  2095. return target;
  2096. }
  2097. return Object.keys(source).reduce(function (acc, key) {
  2098. var value = source[key];
  2099. if (has.call(acc, key)) {
  2100. acc[key] = merge(acc[key], value, options);
  2101. } else {
  2102. acc[key] = value;
  2103. }
  2104. return acc;
  2105. }, mergeTarget);
  2106. };
  2107. var assign = function assignSingleSource(target, source) {
  2108. return Object.keys(source).reduce(function (acc, key) {
  2109. acc[key] = source[key];
  2110. return acc;
  2111. }, target);
  2112. };
  2113. var decode = function (str, decoder, charset) {
  2114. var strWithoutPlus = str.replace(/\+/g, ' ');
  2115. if (charset === 'iso-8859-1') {
  2116. return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
  2117. }
  2118. try {
  2119. return decodeURIComponent(strWithoutPlus);
  2120. } catch (e) {
  2121. return strWithoutPlus;
  2122. }
  2123. };
  2124. var limit = 1024;
  2125. var encode = function encode(str, defaultEncoder, charset, kind, format) {
  2126. if (str.length === 0) {
  2127. return str;
  2128. }
  2129. var string = str;
  2130. if (typeof str === 'symbol') {
  2131. string = Symbol.prototype.toString.call(str);
  2132. } else if (typeof str !== 'string') {
  2133. string = String(str);
  2134. }
  2135. if (charset === 'iso-8859-1') {
  2136. return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
  2137. return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
  2138. });
  2139. }
  2140. var out = '';
  2141. for (var j = 0; j < string.length; j += limit) {
  2142. var segment = string.length >= limit ? string.slice(j, j + limit) : string;
  2143. var arr = [];
  2144. for (var i = 0; i < segment.length; ++i) {
  2145. var c = segment.charCodeAt(i);
  2146. if (c === 0x2D || c === 0x2E || c === 0x5F || c === 0x7E || c >= 0x30 && c <= 0x39 || c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || format === formats.RFC1738 && (c === 0x28 || c === 0x29)) {
  2147. arr[arr.length] = segment.charAt(i);
  2148. continue;
  2149. }
  2150. if (c < 0x80) {
  2151. arr[arr.length] = hexTable[c];
  2152. continue;
  2153. }
  2154. if (c < 0x800) {
  2155. arr[arr.length] = hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F];
  2156. continue;
  2157. }
  2158. if (c < 0xD800 || c >= 0xE000) {
  2159. arr[arr.length] = hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
  2160. continue;
  2161. }
  2162. i += 1;
  2163. c = 0x10000 + ((c & 0x3FF) << 10 | segment.charCodeAt(i) & 0x3FF);
  2164. arr[arr.length] = hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
  2165. }
  2166. out += arr.join('');
  2167. }
  2168. return out;
  2169. };
  2170. var compact = function compact(value) {
  2171. var queue = [{
  2172. obj: {
  2173. o: value
  2174. },
  2175. prop: 'o'
  2176. }];
  2177. var refs = [];
  2178. for (var i = 0; i < queue.length; ++i) {
  2179. var item = queue[i];
  2180. var obj = item.obj[item.prop];
  2181. var keys = Object.keys(obj);
  2182. for (var j = 0; j < keys.length; ++j) {
  2183. var key = keys[j];
  2184. var val = obj[key];
  2185. if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
  2186. queue.push({
  2187. obj: obj,
  2188. prop: key
  2189. });
  2190. refs.push(val);
  2191. }
  2192. }
  2193. }
  2194. compactQueue(queue);
  2195. return value;
  2196. };
  2197. var isRegExp = function isRegExp(obj) {
  2198. return Object.prototype.toString.call(obj) === '[object RegExp]';
  2199. };
  2200. var isBuffer = function isBuffer(obj) {
  2201. if (!obj || typeof obj !== 'object') {
  2202. return false;
  2203. }
  2204. return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
  2205. };
  2206. var combine = function combine(a, b) {
  2207. return [].concat(a, b);
  2208. };
  2209. var maybeMap = function maybeMap(val, fn) {
  2210. if (isArray(val)) {
  2211. var mapped = [];
  2212. for (var i = 0; i < val.length; i += 1) {
  2213. mapped.push(fn(val[i]));
  2214. }
  2215. return mapped;
  2216. }
  2217. return fn(val);
  2218. };
  2219. module.exports = {
  2220. arrayToObject: arrayToObject,
  2221. assign: assign,
  2222. combine: combine,
  2223. compact: compact,
  2224. decode: decode,
  2225. encode: encode,
  2226. isBuffer: isBuffer,
  2227. isRegExp: isRegExp,
  2228. maybeMap: maybeMap,
  2229. merge: merge
  2230. };
  2231. },{"./formats":26}],31:[function(require,module,exports){
  2232. 'use strict';
  2233. var GetIntrinsic = require('get-intrinsic');
  2234. var define = require('define-data-property');
  2235. var hasDescriptors = require('has-property-descriptors')();
  2236. var gOPD = require('gopd');
  2237. var $TypeError = require('es-errors/type');
  2238. var $floor = GetIntrinsic('%Math.floor%');
  2239. module.exports = function setFunctionLength(fn, length) {
  2240. if (typeof fn !== 'function') {
  2241. throw new $TypeError('`fn` is not a function');
  2242. }
  2243. if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {
  2244. throw new $TypeError('`length` must be a positive 32-bit integer');
  2245. }
  2246. var loose = arguments.length > 2 && !!arguments[2];
  2247. var functionLengthIsConfigurable = true;
  2248. var functionLengthIsWritable = true;
  2249. if ('length' in fn && gOPD) {
  2250. var desc = gOPD(fn, 'length');
  2251. if (desc && !desc.configurable) {
  2252. functionLengthIsConfigurable = false;
  2253. }
  2254. if (desc && !desc.writable) {
  2255. functionLengthIsWritable = false;
  2256. }
  2257. }
  2258. if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
  2259. if (hasDescriptors) {
  2260. define(fn, 'length', length, true, true);
  2261. } else {
  2262. define(fn, 'length', length);
  2263. }
  2264. }
  2265. return fn;
  2266. };
  2267. },{"define-data-property":5,"es-errors/type":12,"get-intrinsic":17,"gopd":18,"has-property-descriptors":19}],32:[function(require,module,exports){
  2268. 'use strict';
  2269. var GetIntrinsic = require('get-intrinsic');
  2270. var callBound = require('call-bind/callBound');
  2271. var inspect = require('object-inspect');
  2272. var $TypeError = require('es-errors/type');
  2273. var $WeakMap = GetIntrinsic('%WeakMap%', true);
  2274. var $Map = GetIntrinsic('%Map%', true);
  2275. var $weakMapGet = callBound('WeakMap.prototype.get', true);
  2276. var $weakMapSet = callBound('WeakMap.prototype.set', true);
  2277. var $weakMapHas = callBound('WeakMap.prototype.has', true);
  2278. var $mapGet = callBound('Map.prototype.get', true);
  2279. var $mapSet = callBound('Map.prototype.set', true);
  2280. var $mapHas = callBound('Map.prototype.has', true);
  2281. var listGetNode = function (list, key) {
  2282. var prev = list;
  2283. var curr;
  2284. for (; (curr = prev.next) !== null; prev = curr) {
  2285. if (curr.key === key) {
  2286. prev.next = curr.next;
  2287. curr.next = list.next;
  2288. list.next = curr;
  2289. return curr;
  2290. }
  2291. }
  2292. };
  2293. var listGet = function (objects, key) {
  2294. var node = listGetNode(objects, key);
  2295. return node && node.value;
  2296. };
  2297. var listSet = function (objects, key, value) {
  2298. var node = listGetNode(objects, key);
  2299. if (node) {
  2300. node.value = value;
  2301. } else {
  2302. objects.next = {
  2303. key: key,
  2304. next: objects.next,
  2305. value: value
  2306. };
  2307. }
  2308. };
  2309. var listHas = function (objects, key) {
  2310. return !!listGetNode(objects, key);
  2311. };
  2312. module.exports = function getSideChannel() {
  2313. var $wm;
  2314. var $m;
  2315. var $o;
  2316. var channel = {
  2317. assert: function (key) {
  2318. if (!channel.has(key)) {
  2319. throw new $TypeError('Side channel does not contain ' + inspect(key));
  2320. }
  2321. },
  2322. get: function (key) {
  2323. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  2324. if ($wm) {
  2325. return $weakMapGet($wm, key);
  2326. }
  2327. } else if ($Map) {
  2328. if ($m) {
  2329. return $mapGet($m, key);
  2330. }
  2331. } else {
  2332. if ($o) {
  2333. return listGet($o, key);
  2334. }
  2335. }
  2336. },
  2337. has: function (key) {
  2338. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  2339. if ($wm) {
  2340. return $weakMapHas($wm, key);
  2341. }
  2342. } else if ($Map) {
  2343. if ($m) {
  2344. return $mapHas($m, key);
  2345. }
  2346. } else {
  2347. if ($o) {
  2348. return listHas($o, key);
  2349. }
  2350. }
  2351. return false;
  2352. },
  2353. set: function (key, value) {
  2354. if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
  2355. if (!$wm) {
  2356. $wm = new $WeakMap();
  2357. }
  2358. $weakMapSet($wm, key, value);
  2359. } else if ($Map) {
  2360. if (!$m) {
  2361. $m = new $Map();
  2362. }
  2363. $mapSet($m, key, value);
  2364. } else {
  2365. if (!$o) {
  2366. $o = {
  2367. key: {},
  2368. next: null
  2369. };
  2370. }
  2371. listSet($o, key, value);
  2372. }
  2373. }
  2374. };
  2375. return channel;
  2376. };
  2377. },{"call-bind/callBound":2,"es-errors/type":12,"get-intrinsic":17,"object-inspect":24}],33:[function(require,module,exports){
  2378. const defaults = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts'];
  2379. class Agent {
  2380. constructor() {
  2381. this._defaults = [];
  2382. }
  2383. _setDefaults(request) {
  2384. for (const def of this._defaults) {
  2385. request[def.fn](...def.args);
  2386. }
  2387. }
  2388. }
  2389. for (const fn of defaults) {
  2390. Agent.prototype[fn] = function () {
  2391. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2392. args[_key] = arguments[_key];
  2393. }
  2394. this._defaults.push({
  2395. fn,
  2396. args
  2397. });
  2398. return this;
  2399. };
  2400. }
  2401. module.exports = Agent;
  2402. },{}],34:[function(require,module,exports){
  2403. let root;
  2404. if (typeof window !== 'undefined') {
  2405. root = window;
  2406. } else if (typeof self === 'undefined') {
  2407. console.warn('Using browser-only version of superagent in non-browser environment');
  2408. root = this;
  2409. } else {
  2410. root = self;
  2411. }
  2412. const Emitter = require('component-emitter');
  2413. const safeStringify = require('fast-safe-stringify');
  2414. const qs = require('qs');
  2415. const RequestBase = require('./request-base');
  2416. const {
  2417. isObject,
  2418. mixin,
  2419. hasOwn
  2420. } = require('./utils');
  2421. const ResponseBase = require('./response-base');
  2422. const Agent = require('./agent-base');
  2423. function noop() {}
  2424. module.exports = function (method, url) {
  2425. if (typeof url === 'function') {
  2426. return new exports.Request('GET', method).end(url);
  2427. }
  2428. if (arguments.length === 1) {
  2429. return new exports.Request('GET', method);
  2430. }
  2431. return new exports.Request(method, url);
  2432. };
  2433. exports = module.exports;
  2434. const request = exports;
  2435. exports.Request = Request;
  2436. request.getXHR = () => {
  2437. if (root.XMLHttpRequest) {
  2438. return new root.XMLHttpRequest();
  2439. }
  2440. throw new Error('Browser-only version of superagent could not find XHR');
  2441. };
  2442. const trim = ''.trim ? s => s.trim() : s => s.replace(/(^\s*|\s*$)/g, '');
  2443. function serialize(object) {
  2444. if (!isObject(object)) return object;
  2445. const pairs = [];
  2446. for (const key in object) {
  2447. if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
  2448. }
  2449. return pairs.join('&');
  2450. }
  2451. function pushEncodedKeyValuePair(pairs, key, value) {
  2452. if (value === undefined) return;
  2453. if (value === null) {
  2454. pairs.push(encodeURI(key));
  2455. return;
  2456. }
  2457. if (Array.isArray(value)) {
  2458. for (const v of value) {
  2459. pushEncodedKeyValuePair(pairs, key, v);
  2460. }
  2461. } else if (isObject(value)) {
  2462. for (const subkey in value) {
  2463. if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs, `${key}[${subkey}]`, value[subkey]);
  2464. }
  2465. } else {
  2466. pairs.push(encodeURI(key) + '=' + encodeURIComponent(value));
  2467. }
  2468. }
  2469. request.serializeObject = serialize;
  2470. function parseString(string_) {
  2471. const object = {};
  2472. const pairs = string_.split('&');
  2473. let pair;
  2474. let pos;
  2475. for (let i = 0, length_ = pairs.length; i < length_; ++i) {
  2476. pair = pairs[i];
  2477. pos = pair.indexOf('=');
  2478. if (pos === -1) {
  2479. object[decodeURIComponent(pair)] = '';
  2480. } else {
  2481. object[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));
  2482. }
  2483. }
  2484. return object;
  2485. }
  2486. request.parseString = parseString;
  2487. request.types = {
  2488. html: 'text/html',
  2489. json: 'application/json',
  2490. xml: 'text/xml',
  2491. urlencoded: 'application/x-www-form-urlencoded',
  2492. form: 'application/x-www-form-urlencoded',
  2493. 'form-data': 'application/x-www-form-urlencoded'
  2494. };
  2495. request.serialize = {
  2496. 'application/x-www-form-urlencoded': qs.stringify,
  2497. 'application/json': safeStringify
  2498. };
  2499. request.parse = {
  2500. 'application/x-www-form-urlencoded': parseString,
  2501. 'application/json': JSON.parse
  2502. };
  2503. function parseHeader(string_) {
  2504. const lines = string_.split(/\r?\n/);
  2505. const fields = {};
  2506. let index;
  2507. let line;
  2508. let field;
  2509. let value;
  2510. for (let i = 0, length_ = lines.length; i < length_; ++i) {
  2511. line = lines[i];
  2512. index = line.indexOf(':');
  2513. if (index === -1) {
  2514. continue;
  2515. }
  2516. field = line.slice(0, index).toLowerCase();
  2517. value = trim(line.slice(index + 1));
  2518. fields[field] = value;
  2519. }
  2520. return fields;
  2521. }
  2522. function isJSON(mime) {
  2523. return /[/+]json($|[^-\w])/i.test(mime);
  2524. }
  2525. function Response(request_) {
  2526. this.req = request_;
  2527. this.xhr = this.req.xhr;
  2528. this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
  2529. this.statusText = this.req.xhr.statusText;
  2530. let {
  2531. status
  2532. } = this.xhr;
  2533. if (status === 1223) {
  2534. status = 204;
  2535. }
  2536. this._setStatusProperties(status);
  2537. this.headers = parseHeader(this.xhr.getAllResponseHeaders());
  2538. this.header = this.headers;
  2539. this.header['content-type'] = this.xhr.getResponseHeader('content-type');
  2540. this._setHeaderProperties(this.header);
  2541. if (this.text === null && request_._responseType) {
  2542. this.body = this.xhr.response;
  2543. } else {
  2544. this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response);
  2545. }
  2546. }
  2547. mixin(Response.prototype, ResponseBase.prototype);
  2548. Response.prototype._parseBody = function (string_) {
  2549. let parse = request.parse[this.type];
  2550. if (this.req._parser) {
  2551. return this.req._parser(this, string_);
  2552. }
  2553. if (!parse && isJSON(this.type)) {
  2554. parse = request.parse['application/json'];
  2555. }
  2556. return parse && string_ && (string_.length > 0 || string_ instanceof Object) ? parse(string_) : null;
  2557. };
  2558. Response.prototype.toError = function () {
  2559. const {
  2560. req
  2561. } = this;
  2562. const {
  2563. method
  2564. } = req;
  2565. const {
  2566. url
  2567. } = req;
  2568. const message = `cannot ${method} ${url} (${this.status})`;
  2569. const error = new Error(message);
  2570. error.status = this.status;
  2571. error.method = method;
  2572. error.url = url;
  2573. return error;
  2574. };
  2575. request.Response = Response;
  2576. function Request(method, url) {
  2577. const self = this;
  2578. this._query = this._query || [];
  2579. this.method = method;
  2580. this.url = url;
  2581. this.header = {};
  2582. this._header = {};
  2583. this.on('end', () => {
  2584. let error = null;
  2585. let res = null;
  2586. try {
  2587. res = new Response(self);
  2588. } catch (err) {
  2589. error = new Error('Parser is unable to parse the response');
  2590. error.parse = true;
  2591. error.original = err;
  2592. if (self.xhr) {
  2593. error.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response;
  2594. error.status = self.xhr.status ? self.xhr.status : null;
  2595. error.statusCode = error.status;
  2596. } else {
  2597. error.rawResponse = null;
  2598. error.status = null;
  2599. }
  2600. return self.callback(error);
  2601. }
  2602. self.emit('response', res);
  2603. let new_error;
  2604. try {
  2605. if (!self._isResponseOK(res)) {
  2606. new_error = new Error(res.statusText || res.text || 'Unsuccessful HTTP response');
  2607. }
  2608. } catch (err) {
  2609. new_error = err;
  2610. }
  2611. if (new_error) {
  2612. new_error.original = error;
  2613. new_error.response = res;
  2614. new_error.status = new_error.status || res.status;
  2615. self.callback(new_error, res);
  2616. } else {
  2617. self.callback(null, res);
  2618. }
  2619. });
  2620. }
  2621. Emitter(Request.prototype);
  2622. mixin(Request.prototype, RequestBase.prototype);
  2623. Request.prototype.type = function (type) {
  2624. this.set('Content-Type', request.types[type] || type);
  2625. return this;
  2626. };
  2627. Request.prototype.accept = function (type) {
  2628. this.set('Accept', request.types[type] || type);
  2629. return this;
  2630. };
  2631. Request.prototype.auth = function (user, pass, options) {
  2632. if (arguments.length === 1) pass = '';
  2633. if (typeof pass === 'object' && pass !== null) {
  2634. options = pass;
  2635. pass = '';
  2636. }
  2637. if (!options) {
  2638. options = {
  2639. type: typeof btoa === 'function' ? 'basic' : 'auto'
  2640. };
  2641. }
  2642. const encoder = options.encoder ? options.encoder : string => {
  2643. if (typeof btoa === 'function') {
  2644. return btoa(string);
  2645. }
  2646. throw new Error('Cannot use basic auth, btoa is not a function');
  2647. };
  2648. return this._auth(user, pass, options, encoder);
  2649. };
  2650. Request.prototype.query = function (value) {
  2651. if (typeof value !== 'string') value = serialize(value);
  2652. if (value) this._query.push(value);
  2653. return this;
  2654. };
  2655. Request.prototype.attach = function (field, file, options) {
  2656. if (file) {
  2657. if (this._data) {
  2658. throw new Error("superagent can't mix .send() and .attach()");
  2659. }
  2660. this._getFormData().append(field, file, options || file.name);
  2661. }
  2662. return this;
  2663. };
  2664. Request.prototype._getFormData = function () {
  2665. if (!this._formData) {
  2666. this._formData = new root.FormData();
  2667. }
  2668. return this._formData;
  2669. };
  2670. Request.prototype.callback = function (error, res) {
  2671. if (this._shouldRetry(error, res)) {
  2672. return this._retry();
  2673. }
  2674. const fn = this._callback;
  2675. this.clearTimeout();
  2676. if (error) {
  2677. if (this._maxRetries) error.retries = this._retries - 1;
  2678. this.emit('error', error);
  2679. }
  2680. fn(error, res);
  2681. };
  2682. Request.prototype.crossDomainError = function () {
  2683. const error = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
  2684. error.crossDomain = true;
  2685. error.status = this.status;
  2686. error.method = this.method;
  2687. error.url = this.url;
  2688. this.callback(error);
  2689. };
  2690. Request.prototype.agent = function () {
  2691. console.warn('This is not supported in browser version of superagent');
  2692. return this;
  2693. };
  2694. Request.prototype.ca = Request.prototype.agent;
  2695. Request.prototype.buffer = Request.prototype.ca;
  2696. Request.prototype.write = () => {
  2697. throw new Error('Streaming is not supported in browser version of superagent');
  2698. };
  2699. Request.prototype.pipe = Request.prototype.write;
  2700. Request.prototype._isHost = function (object) {
  2701. return object && typeof object === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
  2702. };
  2703. Request.prototype.end = function (fn) {
  2704. if (this._endCalled) {
  2705. console.warn('Warning: .end() was called twice. This is not supported in superagent');
  2706. }
  2707. this._endCalled = true;
  2708. this._callback = fn || noop;
  2709. this._finalizeQueryString();
  2710. this._end();
  2711. };
  2712. Request.prototype._setUploadTimeout = function () {
  2713. const self = this;
  2714. if (this._uploadTimeout && !this._uploadTimeoutTimer) {
  2715. this._uploadTimeoutTimer = setTimeout(() => {
  2716. self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
  2717. }, this._uploadTimeout);
  2718. }
  2719. };
  2720. Request.prototype._end = function () {
  2721. if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
  2722. const self = this;
  2723. this.xhr = request.getXHR();
  2724. const {
  2725. xhr
  2726. } = this;
  2727. let data = this._formData || this._data;
  2728. this._setTimeouts();
  2729. xhr.addEventListener('readystatechange', () => {
  2730. const {
  2731. readyState
  2732. } = xhr;
  2733. if (readyState >= 2 && self._responseTimeoutTimer) {
  2734. clearTimeout(self._responseTimeoutTimer);
  2735. }
  2736. if (readyState !== 4) {
  2737. return;
  2738. }
  2739. let status;
  2740. try {
  2741. status = xhr.status;
  2742. } catch (err) {
  2743. status = 0;
  2744. }
  2745. if (!status) {
  2746. if (self.timedout || self._aborted) return;
  2747. return self.crossDomainError();
  2748. }
  2749. self.emit('end');
  2750. });
  2751. const handleProgress = (direction, e) => {
  2752. if (e.total > 0) {
  2753. e.percent = e.loaded / e.total * 100;
  2754. if (e.percent === 100) {
  2755. clearTimeout(self._uploadTimeoutTimer);
  2756. }
  2757. }
  2758. e.direction = direction;
  2759. self.emit('progress', e);
  2760. };
  2761. if (this.hasListeners('progress')) {
  2762. try {
  2763. xhr.addEventListener('progress', handleProgress.bind(null, 'download'));
  2764. if (xhr.upload) {
  2765. xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
  2766. }
  2767. } catch (err) {}
  2768. }
  2769. if (xhr.upload) {
  2770. this._setUploadTimeout();
  2771. }
  2772. try {
  2773. if (this.username && this.password) {
  2774. xhr.open(this.method, this.url, true, this.username, this.password);
  2775. } else {
  2776. xhr.open(this.method, this.url, true);
  2777. }
  2778. } catch (err) {
  2779. return this.callback(err);
  2780. }
  2781. if (this._withCredentials) xhr.withCredentials = true;
  2782. if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
  2783. const contentType = this._header['content-type'];
  2784. let serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
  2785. if (!serialize && isJSON(contentType)) {
  2786. serialize = request.serialize['application/json'];
  2787. }
  2788. if (serialize) data = serialize(data);
  2789. }
  2790. for (const field in this.header) {
  2791. if (this.header[field] === null) continue;
  2792. if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
  2793. }
  2794. if (this._responseType) {
  2795. xhr.responseType = this._responseType;
  2796. }
  2797. this.emit('request', this);
  2798. xhr.send(typeof data === 'undefined' ? null : data);
  2799. };
  2800. request.agent = () => new Agent();
  2801. for (const method of ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']) {
  2802. Agent.prototype[method.toLowerCase()] = function (url, fn) {
  2803. const request_ = new request.Request(method, url);
  2804. this._setDefaults(request_);
  2805. if (fn) {
  2806. request_.end(fn);
  2807. }
  2808. return request_;
  2809. };
  2810. }
  2811. Agent.prototype.del = Agent.prototype.delete;
  2812. request.get = (url, data, fn) => {
  2813. const request_ = request('GET', url);
  2814. if (typeof data === 'function') {
  2815. fn = data;
  2816. data = null;
  2817. }
  2818. if (data) request_.query(data);
  2819. if (fn) request_.end(fn);
  2820. return request_;
  2821. };
  2822. request.head = (url, data, fn) => {
  2823. const request_ = request('HEAD', url);
  2824. if (typeof data === 'function') {
  2825. fn = data;
  2826. data = null;
  2827. }
  2828. if (data) request_.query(data);
  2829. if (fn) request_.end(fn);
  2830. return request_;
  2831. };
  2832. request.options = (url, data, fn) => {
  2833. const request_ = request('OPTIONS', url);
  2834. if (typeof data === 'function') {
  2835. fn = data;
  2836. data = null;
  2837. }
  2838. if (data) request_.send(data);
  2839. if (fn) request_.end(fn);
  2840. return request_;
  2841. };
  2842. function del(url, data, fn) {
  2843. const request_ = request('DELETE', url);
  2844. if (typeof data === 'function') {
  2845. fn = data;
  2846. data = null;
  2847. }
  2848. if (data) request_.send(data);
  2849. if (fn) request_.end(fn);
  2850. return request_;
  2851. }
  2852. request.del = del;
  2853. request.delete = del;
  2854. request.patch = (url, data, fn) => {
  2855. const request_ = request('PATCH', url);
  2856. if (typeof data === 'function') {
  2857. fn = data;
  2858. data = null;
  2859. }
  2860. if (data) request_.send(data);
  2861. if (fn) request_.end(fn);
  2862. return request_;
  2863. };
  2864. request.post = (url, data, fn) => {
  2865. const request_ = request('POST', url);
  2866. if (typeof data === 'function') {
  2867. fn = data;
  2868. data = null;
  2869. }
  2870. if (data) request_.send(data);
  2871. if (fn) request_.end(fn);
  2872. return request_;
  2873. };
  2874. request.put = (url, data, fn) => {
  2875. const request_ = request('PUT', url);
  2876. if (typeof data === 'function') {
  2877. fn = data;
  2878. data = null;
  2879. }
  2880. if (data) request_.send(data);
  2881. if (fn) request_.end(fn);
  2882. return request_;
  2883. };
  2884. },{"./agent-base":33,"./request-base":35,"./response-base":36,"./utils":37,"component-emitter":4,"fast-safe-stringify":14,"qs":27}],35:[function(require,module,exports){
  2885. (function (process){(function (){
  2886. const semver = require('semver');
  2887. const {
  2888. isObject,
  2889. hasOwn
  2890. } = require('./utils');
  2891. module.exports = RequestBase;
  2892. function RequestBase() {}
  2893. RequestBase.prototype.clearTimeout = function () {
  2894. clearTimeout(this._timer);
  2895. clearTimeout(this._responseTimeoutTimer);
  2896. clearTimeout(this._uploadTimeoutTimer);
  2897. delete this._timer;
  2898. delete this._responseTimeoutTimer;
  2899. delete this._uploadTimeoutTimer;
  2900. return this;
  2901. };
  2902. RequestBase.prototype.parse = function (fn) {
  2903. this._parser = fn;
  2904. return this;
  2905. };
  2906. RequestBase.prototype.responseType = function (value) {
  2907. this._responseType = value;
  2908. return this;
  2909. };
  2910. RequestBase.prototype.serialize = function (fn) {
  2911. this._serializer = fn;
  2912. return this;
  2913. };
  2914. RequestBase.prototype.timeout = function (options) {
  2915. if (!options || typeof options !== 'object') {
  2916. this._timeout = options;
  2917. this._responseTimeout = 0;
  2918. this._uploadTimeout = 0;
  2919. return this;
  2920. }
  2921. for (const option in options) {
  2922. if (hasOwn(options, option)) {
  2923. switch (option) {
  2924. case 'deadline':
  2925. this._timeout = options.deadline;
  2926. break;
  2927. case 'response':
  2928. this._responseTimeout = options.response;
  2929. break;
  2930. case 'upload':
  2931. this._uploadTimeout = options.upload;
  2932. break;
  2933. default:
  2934. console.warn('Unknown timeout option', option);
  2935. }
  2936. }
  2937. }
  2938. return this;
  2939. };
  2940. RequestBase.prototype.retry = function (count, fn) {
  2941. if (arguments.length === 0 || count === true) count = 1;
  2942. if (count <= 0) count = 0;
  2943. this._maxRetries = count;
  2944. this._retries = 0;
  2945. this._retryCallback = fn;
  2946. return this;
  2947. };
  2948. const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
  2949. const STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
  2950. RequestBase.prototype._shouldRetry = function (error, res) {
  2951. if (!this._maxRetries || this._retries++ >= this._maxRetries) {
  2952. return false;
  2953. }
  2954. if (this._retryCallback) {
  2955. try {
  2956. const override = this._retryCallback(error, res);
  2957. if (override === true) return true;
  2958. if (override === false) return false;
  2959. } catch (err) {
  2960. console.error(err);
  2961. }
  2962. }
  2963. if (res && res.status && STATUS_CODES.has(res.status)) return true;
  2964. if (error) {
  2965. if (error.code && ERROR_CODES.has(error.code)) return true;
  2966. if (error.timeout && error.code === 'ECONNABORTED') return true;
  2967. if (error.crossDomain) return true;
  2968. }
  2969. return false;
  2970. };
  2971. RequestBase.prototype._retry = function () {
  2972. this.clearTimeout();
  2973. if (this.req) {
  2974. this.req = null;
  2975. this.req = this.request();
  2976. }
  2977. this._aborted = false;
  2978. this.timedout = false;
  2979. this.timedoutError = null;
  2980. return this._end();
  2981. };
  2982. RequestBase.prototype.then = function (resolve, reject) {
  2983. if (!this._fullfilledPromise) {
  2984. const self = this;
  2985. if (this._endCalled) {
  2986. console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
  2987. }
  2988. this._fullfilledPromise = new Promise((resolve, reject) => {
  2989. self.on('abort', () => {
  2990. if (this._maxRetries && this._maxRetries > this._retries) {
  2991. return;
  2992. }
  2993. if (this.timedout && this.timedoutError) {
  2994. reject(this.timedoutError);
  2995. return;
  2996. }
  2997. const error = new Error('Aborted');
  2998. error.code = 'ABORTED';
  2999. error.status = this.status;
  3000. error.method = this.method;
  3001. error.url = this.url;
  3002. reject(error);
  3003. });
  3004. self.end((error, res) => {
  3005. if (error) reject(error);else resolve(res);
  3006. });
  3007. });
  3008. }
  3009. return this._fullfilledPromise.then(resolve, reject);
  3010. };
  3011. RequestBase.prototype.catch = function (callback) {
  3012. return this.then(undefined, callback);
  3013. };
  3014. RequestBase.prototype.use = function (fn) {
  3015. fn(this);
  3016. return this;
  3017. };
  3018. RequestBase.prototype.ok = function (callback) {
  3019. if (typeof callback !== 'function') throw new Error('Callback required');
  3020. this._okCallback = callback;
  3021. return this;
  3022. };
  3023. RequestBase.prototype._isResponseOK = function (res) {
  3024. if (!res) {
  3025. return false;
  3026. }
  3027. if (this._okCallback) {
  3028. return this._okCallback(res);
  3029. }
  3030. return res.status >= 200 && res.status < 300;
  3031. };
  3032. RequestBase.prototype.get = function (field) {
  3033. return this._header[field.toLowerCase()];
  3034. };
  3035. RequestBase.prototype.getHeader = RequestBase.prototype.get;
  3036. RequestBase.prototype.set = function (field, value) {
  3037. if (isObject(field)) {
  3038. for (const key in field) {
  3039. if (hasOwn(field, key)) this.set(key, field[key]);
  3040. }
  3041. return this;
  3042. }
  3043. this._header[field.toLowerCase()] = value;
  3044. this.header[field] = value;
  3045. return this;
  3046. };
  3047. RequestBase.prototype.unset = function (field) {
  3048. delete this._header[field.toLowerCase()];
  3049. delete this.header[field];
  3050. return this;
  3051. };
  3052. RequestBase.prototype.field = function (name, value, options) {
  3053. if (name === null || undefined === name) {
  3054. throw new Error('.field(name, val) name can not be empty');
  3055. }
  3056. if (this._data) {
  3057. throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
  3058. }
  3059. if (isObject(name)) {
  3060. for (const key in name) {
  3061. if (hasOwn(name, key)) this.field(key, name[key]);
  3062. }
  3063. return this;
  3064. }
  3065. if (Array.isArray(value)) {
  3066. for (const i in value) {
  3067. if (hasOwn(value, i)) this.field(name, value[i]);
  3068. }
  3069. return this;
  3070. }
  3071. if (value === null || undefined === value) {
  3072. throw new Error('.field(name, val) val can not be empty');
  3073. }
  3074. if (typeof value === 'boolean') {
  3075. value = String(value);
  3076. }
  3077. if (options) this._getFormData().append(name, value, options);else this._getFormData().append(name, value);
  3078. return this;
  3079. };
  3080. RequestBase.prototype.abort = function () {
  3081. if (this._aborted) {
  3082. return this;
  3083. }
  3084. this._aborted = true;
  3085. if (this.xhr) this.xhr.abort();
  3086. if (this.req) {
  3087. if (semver.gte(process.version, 'v13.0.0') && semver.lt(process.version, 'v14.0.0')) {
  3088. throw new Error('Superagent does not work in v13 properly with abort() due to Node.js core changes');
  3089. }
  3090. this.req.abort();
  3091. }
  3092. this.clearTimeout();
  3093. this.emit('abort');
  3094. return this;
  3095. };
  3096. RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
  3097. switch (options.type) {
  3098. case 'basic':
  3099. this.set('Authorization', `Basic ${base64Encoder(`${user}:${pass}`)}`);
  3100. break;
  3101. case 'auto':
  3102. this.username = user;
  3103. this.password = pass;
  3104. break;
  3105. case 'bearer':
  3106. this.set('Authorization', `Bearer ${user}`);
  3107. break;
  3108. default:
  3109. break;
  3110. }
  3111. return this;
  3112. };
  3113. RequestBase.prototype.withCredentials = function (on) {
  3114. if (on === undefined) on = true;
  3115. this._withCredentials = on;
  3116. return this;
  3117. };
  3118. RequestBase.prototype.redirects = function (n) {
  3119. this._maxRedirects = n;
  3120. return this;
  3121. };
  3122. RequestBase.prototype.maxResponseSize = function (n) {
  3123. if (typeof n !== 'number') {
  3124. throw new TypeError('Invalid argument');
  3125. }
  3126. this._maxResponseSize = n;
  3127. return this;
  3128. };
  3129. RequestBase.prototype.toJSON = function () {
  3130. return {
  3131. method: this.method,
  3132. url: this.url,
  3133. data: this._data,
  3134. headers: this._header
  3135. };
  3136. };
  3137. RequestBase.prototype.send = function (data) {
  3138. const isObject_ = isObject(data);
  3139. let type = this._header['content-type'];
  3140. if (this._formData) {
  3141. throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
  3142. }
  3143. if (isObject_ && !this._data) {
  3144. if (Array.isArray(data)) {
  3145. this._data = [];
  3146. } else if (!this._isHost(data)) {
  3147. this._data = {};
  3148. }
  3149. } else if (data && this._data && this._isHost(this._data)) {
  3150. throw new Error("Can't merge these send calls");
  3151. }
  3152. if (isObject_ && isObject(this._data)) {
  3153. for (const key in data) {
  3154. if (typeof data[key] == 'bigint' && !data[key].toJSON) throw new Error('Cannot serialize BigInt value to json');
  3155. if (hasOwn(data, key)) this._data[key] = data[key];
  3156. }
  3157. } else if (typeof data === 'bigint') throw new Error("Cannot send value of type BigInt");else if (typeof data === 'string') {
  3158. if (!type) this.type('form');
  3159. type = this._header['content-type'];
  3160. if (type) type = type.toLowerCase().trim();
  3161. if (type === 'application/x-www-form-urlencoded') {
  3162. this._data = this._data ? `${this._data}&${data}` : data;
  3163. } else {
  3164. this._data = (this._data || '') + data;
  3165. }
  3166. } else {
  3167. this._data = data;
  3168. }
  3169. if (!isObject_ || this._isHost(data)) {
  3170. return this;
  3171. }
  3172. if (!type) this.type('json');
  3173. return this;
  3174. };
  3175. RequestBase.prototype.sortQuery = function (sort) {
  3176. this._sort = typeof sort === 'undefined' ? true : sort;
  3177. return this;
  3178. };
  3179. RequestBase.prototype._finalizeQueryString = function () {
  3180. const query = this._query.join('&');
  3181. if (query) {
  3182. this.url += (this.url.includes('?') ? '&' : '?') + query;
  3183. }
  3184. this._query.length = 0;
  3185. if (this._sort) {
  3186. const index = this.url.indexOf('?');
  3187. if (index >= 0) {
  3188. const queryArray = this.url.slice(index + 1).split('&');
  3189. if (typeof this._sort === 'function') {
  3190. queryArray.sort(this._sort);
  3191. } else {
  3192. queryArray.sort();
  3193. }
  3194. this.url = this.url.slice(0, index) + '?' + queryArray.join('&');
  3195. }
  3196. }
  3197. };
  3198. RequestBase.prototype._appendQueryString = () => {
  3199. console.warn('Unsupported');
  3200. };
  3201. RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
  3202. if (this._aborted) {
  3203. return;
  3204. }
  3205. const error = new Error(`${reason + timeout}ms exceeded`);
  3206. error.timeout = timeout;
  3207. error.code = 'ECONNABORTED';
  3208. error.errno = errno;
  3209. this.timedout = true;
  3210. this.timedoutError = error;
  3211. this.abort();
  3212. this.callback(error);
  3213. };
  3214. RequestBase.prototype._setTimeouts = function () {
  3215. const self = this;
  3216. if (this._timeout && !this._timer) {
  3217. this._timer = setTimeout(() => {
  3218. self._timeoutError('Timeout of ', self._timeout, 'ETIME');
  3219. }, this._timeout);
  3220. }
  3221. if (this._responseTimeout && !this._responseTimeoutTimer) {
  3222. this._responseTimeoutTimer = setTimeout(() => {
  3223. self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
  3224. }, this._responseTimeout);
  3225. }
  3226. };
  3227. }).call(this)}).call(this,require('_process'))
  3228. },{"./utils":37,"_process":25,"semver":1}],36:[function(require,module,exports){
  3229. const utils = require('./utils');
  3230. module.exports = ResponseBase;
  3231. function ResponseBase() {}
  3232. ResponseBase.prototype.get = function (field) {
  3233. return this.header[field.toLowerCase()];
  3234. };
  3235. ResponseBase.prototype._setHeaderProperties = function (header) {
  3236. const ct = header['content-type'] || '';
  3237. this.type = utils.type(ct);
  3238. const parameters = utils.params(ct);
  3239. for (const key in parameters) {
  3240. if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
  3241. }
  3242. this.links = {};
  3243. try {
  3244. if (header.link) {
  3245. this.links = utils.parseLinks(header.link);
  3246. }
  3247. } catch (err) {}
  3248. };
  3249. ResponseBase.prototype._setStatusProperties = function (status) {
  3250. const type = Math.trunc(status / 100);
  3251. this.statusCode = status;
  3252. this.status = this.statusCode;
  3253. this.statusType = type;
  3254. this.info = type === 1;
  3255. this.ok = type === 2;
  3256. this.redirect = type === 3;
  3257. this.clientError = type === 4;
  3258. this.serverError = type === 5;
  3259. this.error = type === 4 || type === 5 ? this.toError() : false;
  3260. this.created = status === 201;
  3261. this.accepted = status === 202;
  3262. this.noContent = status === 204;
  3263. this.badRequest = status === 400;
  3264. this.unauthorized = status === 401;
  3265. this.notAcceptable = status === 406;
  3266. this.forbidden = status === 403;
  3267. this.notFound = status === 404;
  3268. this.unprocessableEntity = status === 422;
  3269. };
  3270. },{"./utils":37}],37:[function(require,module,exports){
  3271. exports.type = string_ => string_.split(/ *; */).shift();
  3272. exports.params = value => {
  3273. const object = {};
  3274. for (const string_ of value.split(/ *; */)) {
  3275. const parts = string_.split(/ *= */);
  3276. const key = parts.shift();
  3277. const value = parts.shift();
  3278. if (key && value) object[key] = value;
  3279. }
  3280. return object;
  3281. };
  3282. exports.parseLinks = value => {
  3283. const object = {};
  3284. for (const string_ of value.split(/ *, */)) {
  3285. const parts = string_.split(/ *; */);
  3286. const url = parts[0].slice(1, -1);
  3287. const rel = parts[1].split(/ *= */)[1].slice(1, -1);
  3288. object[rel] = url;
  3289. }
  3290. return object;
  3291. };
  3292. exports.cleanHeader = (header, changesOrigin) => {
  3293. delete header['content-type'];
  3294. delete header['content-length'];
  3295. delete header['transfer-encoding'];
  3296. delete header.host;
  3297. if (changesOrigin) {
  3298. delete header.authorization;
  3299. delete header.cookie;
  3300. }
  3301. return header;
  3302. };
  3303. exports.isObject = object => {
  3304. return object !== null && typeof object === 'object';
  3305. };
  3306. exports.hasOwn = Object.hasOwn || function (object, property) {
  3307. if (object == null) {
  3308. throw new TypeError('Cannot convert undefined or null to object');
  3309. }
  3310. return Object.prototype.hasOwnProperty.call(new Object(object), property);
  3311. };
  3312. exports.mixin = (target, source) => {
  3313. for (const key in source) {
  3314. if (exports.hasOwn(source, key)) {
  3315. target[key] = source[key];
  3316. }
  3317. }
  3318. };
  3319. },{}]},{},[34])(34)
  3320. });