@posty5/social-publisher-post 4.2.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11747,8 +11747,14 @@ var require_follow_redirects = __commonJS({
11747
11747
  RedirectableRequest.prototype._sanitizeOptions = function(options) {
11748
11748
  if (!options.headers) {
11749
11749
  options.headers = {};
11750
+ } else if (Array.isArray(options.headers)) {
11751
+ var headerList = options.headers;
11752
+ options.headers = {};
11753
+ for (var i = 0; i < headerList.length; i += 2) {
11754
+ options.headers[headerList[i]] = headerList[i + 1];
11755
+ }
11750
11756
  }
11751
- if (!isArray2(options.sensitiveHeaders)) {
11757
+ if (!Array.isArray(options.sensitiveHeaders)) {
11752
11758
  options.sensitiveHeaders = [];
11753
11759
  }
11754
11760
  if (options.host) {
@@ -12005,9 +12011,6 @@ var require_follow_redirects = __commonJS({
12005
12011
  var dot = subdomain.length - domain.length - 1;
12006
12012
  return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
12007
12013
  }
12008
- function isArray2(value) {
12009
- return value instanceof Array;
12010
- }
12011
12014
  function isString2(value) {
12012
12015
  return typeof value === "string" || value instanceof String;
12013
12016
  }
@@ -12021,7 +12024,7 @@ var require_follow_redirects = __commonJS({
12021
12024
  return URL2 && value instanceof URL2;
12022
12025
  }
12023
12026
  function escapeRegex(regex) {
12024
- return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
12027
+ return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
12025
12028
  }
12026
12029
  module.exports = wrap({ http: http3, https: https2 });
12027
12030
  module.exports.wrap = wrap;
@@ -12190,10 +12193,16 @@ var isPlainObject = (val) => {
12190
12193
  return false;
12191
12194
  }
12192
12195
  const prototype2 = getPrototypeOf(val);
12193
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
12194
- // evidence the value is tagged/iterable, while ignoring members reachable
12195
- // only through shared or terminal prototype boundaries.
12196
- !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
12196
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
12197
+ // value is tagged/iterable, ignoring members reachable only through shared
12198
+ // or terminal prototype boundaries. This is exactly what
12199
+ // hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
12200
+ // above (null, Object.prototype, or a terminal null-prototype template) is
12201
+ // a boundary, so the walk never inspects anything but `val`'s own members,
12202
+ // and stops before even those when `val` is itself the boundary
12203
+ // Object.prototype. Checking that inline avoids allocating the walker's
12204
+ // `seen` list twice per call on the mergeConfig / merge hot path.
12205
+ (isPrototypeBoundary(val, prototype2, true) || !hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator));
12197
12206
  };
12198
12207
  var isEmptyObject = (val) => {
12199
12208
  if (!isObject(val) || isBuffer(val)) {
@@ -12294,11 +12303,21 @@ var isContextDefined = (context) => !isUndefined(context) && context !== _global
12294
12303
  function merge(...objs) {
12295
12304
  const { caseless, skipUndefined } = isContextDefined(this) && this || {};
12296
12305
  const result = {};
12306
+ const lowerCaseKeys = caseless ? /* @__PURE__ */ Object.create(null) : null;
12297
12307
  const assignValue = (val, key) => {
12298
12308
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
12299
12309
  return;
12300
12310
  }
12301
- const targetKey = caseless && typeof key === "string" && findKey(result, key) || key;
12311
+ let targetKey = key;
12312
+ if (lowerCaseKeys && typeof key === "string") {
12313
+ const lowerKey = key.toLowerCase();
12314
+ const knownKey = lowerCaseKeys[lowerKey];
12315
+ if (knownKey !== void 0 && hasOwnProperty(result, knownKey)) {
12316
+ targetKey = knownKey;
12317
+ } else {
12318
+ lowerCaseKeys[lowerKey] = key;
12319
+ }
12320
+ }
12302
12321
  const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : void 0;
12303
12322
  if (isPlainObject(existing) && isPlainObject(val)) {
12304
12323
  result[targetKey] = merge(existing, val);
@@ -12316,7 +12335,7 @@ function merge(...objs) {
12316
12335
  continue;
12317
12336
  }
12318
12337
  forEach(source, assignValue);
12319
- if (typeof source !== "object" || isArray(source)) {
12338
+ if (typeof source !== "object" || isArray(source) || !Object.getOwnPropertySymbols) {
12320
12339
  continue;
12321
12340
  }
12322
12341
  const symbols = Object.getOwnPropertySymbols(source);
@@ -12412,7 +12431,24 @@ var toArray = (thing) => {
12412
12431
  if (!thing) return null;
12413
12432
  if (isArray(thing)) return thing;
12414
12433
  let i = thing.length;
12415
- if (!isNumber(i)) return null;
12434
+ if (!Number.isSafeInteger(i) || i < 0 || i > 4294967295) return null;
12435
+ const indexes = /* @__PURE__ */ new Set();
12436
+ const seen = /* @__PURE__ */ new Set();
12437
+ let source = thing;
12438
+ while (source != null && indexes.size < i) {
12439
+ if (seen.has(source)) return null;
12440
+ seen.add(source);
12441
+ const prototype2 = getPrototypeOf(source);
12442
+ if (isPrototypeBoundary(source, prototype2, source === thing)) break;
12443
+ Object.getOwnPropertyNames(source).forEach((key) => {
12444
+ const index = +key;
12445
+ if (Number.isInteger(index) && index >= 0 && index < i && String(index) === key && hasOwnProperty(source, key)) {
12446
+ indexes.add(index);
12447
+ }
12448
+ });
12449
+ source = prototype2;
12450
+ }
12451
+ if (indexes.size !== i) return null;
12416
12452
  const arr = new Array(i);
12417
12453
  while (i-- > 0) {
12418
12454
  arr[i] = thing[i];
@@ -12644,7 +12680,7 @@ var ignoreDuplicateOf = utils_default.toObjectSet([
12644
12680
  "user-agent"
12645
12681
  ]);
12646
12682
  var parseHeaders_default = (rawHeaders) => {
12647
- const parsed = {};
12683
+ const parsed = /* @__PURE__ */ Object.create(null);
12648
12684
  let key;
12649
12685
  let val;
12650
12686
  let i;
@@ -12812,9 +12848,11 @@ function parseParameters(value) {
12812
12848
  return parameters;
12813
12849
  }
12814
12850
  var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
12851
+ var PROTO_HEADER_SLOT = "__Proto__";
12852
+ var headerSlot = (name) => name === "__proto__" ? PROTO_HEADER_SLOT : name;
12815
12853
  function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
12816
12854
  if (utils_default.isFunction(filter2)) {
12817
- return filter2.call(this, value, header);
12855
+ return filter2.call(context, value, header);
12818
12856
  }
12819
12857
  if (isHeaderNameFilter) {
12820
12858
  value = header;
@@ -12859,7 +12897,7 @@ var AxiosHeaders = class {
12859
12897
  }
12860
12898
  const key = utils_default.findKey(self2, lHeader);
12861
12899
  if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
12862
- self2[key || _header] = normalizeValue(_value);
12900
+ self2[headerSlot(key || _header)] = normalizeValue(_value);
12863
12901
  }
12864
12902
  }
12865
12903
  const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
@@ -12952,7 +12990,7 @@ var AxiosHeaders = class {
12952
12990
  }
12953
12991
  normalize(format) {
12954
12992
  const self2 = this;
12955
- const headers = {};
12993
+ const headers = /* @__PURE__ */ Object.create(null);
12956
12994
  utils_default.forEach(this, (value, header) => {
12957
12995
  const key = utils_default.findKey(headers, header);
12958
12996
  if (key) {
@@ -12960,7 +12998,7 @@ var AxiosHeaders = class {
12960
12998
  delete self2[header];
12961
12999
  return;
12962
13000
  }
12963
- const normalized = format ? formatHeader(header) : String(header).trim();
13001
+ const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
12964
13002
  if (normalized !== header) {
12965
13003
  delete self2[header];
12966
13004
  }
@@ -13110,6 +13148,28 @@ function aggregateErrorMessage(error) {
13110
13148
  }).filter(Boolean).join("; ");
13111
13149
  return message || error.name || "AggregateError";
13112
13150
  }
13151
+ var CAUSED_BY_SEPARATOR = "\nCaused by: ";
13152
+ var $causeStack = /* @__PURE__ */ Symbol("causeStack");
13153
+ function getCauseStackIndex(error, stack) {
13154
+ const causeStack = utils_default.hasOwnProp(error, $causeStack) && error[$causeStack];
13155
+ return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
13156
+ }
13157
+ function appendCauseStack(target, source) {
13158
+ try {
13159
+ const sourceStack = source && source.stack;
13160
+ if (typeof sourceStack !== "string" || !sourceStack) {
13161
+ return;
13162
+ }
13163
+ const targetStack = target.stack;
13164
+ if (typeof targetStack !== "string" || !targetStack) {
13165
+ return;
13166
+ }
13167
+ const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
13168
+ target.stack = targetStack + causeStack;
13169
+ Object.defineProperty(target, $causeStack, { __proto__: null, value: causeStack });
13170
+ } catch (e) {
13171
+ }
13172
+ }
13113
13173
  var AxiosError = class _AxiosError extends Error {
13114
13174
  static from(error, code, config, request, response, customProps) {
13115
13175
  let message = error.message;
@@ -13125,6 +13185,7 @@ var AxiosError = class _AxiosError extends Error {
13125
13185
  configurable: true
13126
13186
  });
13127
13187
  axiosError.name = error.name;
13188
+ appendCauseStack(axiosError, error);
13128
13189
  if (error.status != null && axiosError.status == null) {
13129
13190
  axiosError.status = error.status;
13130
13191
  }
@@ -13436,6 +13497,12 @@ function trimHandlers(handlers) {
13436
13497
  handlers.pop();
13437
13498
  }
13438
13499
  }
13500
+ function normalizeHandlerId(id) {
13501
+ if (typeof id === "string" && id !== "" && String(Number(id)) === id) {
13502
+ return Number(id);
13503
+ }
13504
+ return id;
13505
+ }
13439
13506
  function syncHandlerEntries(manager, internals) {
13440
13507
  const handlers = manager.handlers;
13441
13508
  const length = countHandlers(handlers);
@@ -13506,9 +13573,10 @@ var InterceptorManager = class {
13506
13573
  eject(id) {
13507
13574
  const internals = this[$internals2];
13508
13575
  syncHandlerEntries(this, internals);
13509
- const entry = internals.handlerEntries.get(id);
13576
+ const handlerId = normalizeHandlerId(id);
13577
+ const entry = internals.handlerEntries.get(handlerId);
13510
13578
  if (entry) {
13511
- internals.handlerEntries.delete(id);
13579
+ internals.handlerEntries.delete(handlerId);
13512
13580
  if (this.handlers[entry.index] !== entry.handler) {
13513
13581
  return;
13514
13582
  }
@@ -13568,7 +13636,8 @@ var transitional_default = {
13568
13636
  clarifyTimeoutError: false,
13569
13637
  legacyInterceptorReqResOrdering: true,
13570
13638
  advertiseZstdAcceptEncoding: false,
13571
- validateStatusUndefinedResolves: true
13639
+ validateStatusUndefinedResolves: true,
13640
+ encodeBasicAuthUsername: false
13572
13641
  };
13573
13642
  var URLSearchParams_default = url__default.default.URLSearchParams;
13574
13643
 
@@ -13672,6 +13741,24 @@ function arrayToObject(arr) {
13672
13741
  }
13673
13742
  return obj;
13674
13743
  }
13744
+ function normalizeArray(value) {
13745
+ if (!utils_default.isArray(value)) return value;
13746
+ const keys = Object.keys(value);
13747
+ return keys.length !== value.length || keys.some((key, index) => key !== String(index)) ? arrayToObject(value) : value;
13748
+ }
13749
+ function normalizeArrays(obj) {
13750
+ const pending = [obj];
13751
+ while (pending.length) {
13752
+ const target = pending.pop();
13753
+ Object.keys(target).forEach((key) => {
13754
+ const value = target[key] = normalizeArray(target[key]);
13755
+ if (utils_default.isArray(value) || utils_default.isPlainObject(value)) {
13756
+ pending.push(value);
13757
+ }
13758
+ });
13759
+ }
13760
+ return obj;
13761
+ }
13675
13762
  function formDataToJSON(formData) {
13676
13763
  function buildPath(path, value, target, index) {
13677
13764
  throwIfDepthExceeded(index);
@@ -13682,6 +13769,7 @@ function formDataToJSON(formData) {
13682
13769
  name = !name && utils_default.isArray(target) ? target.length : name;
13683
13770
  if (isLast) {
13684
13771
  if (utils_default.hasOwnProp(target, name)) {
13772
+ target[name] = normalizeArray(target[name]);
13685
13773
  target[name] = utils_default.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
13686
13774
  } else {
13687
13775
  target[name] = value;
@@ -13702,7 +13790,7 @@ function formDataToJSON(formData) {
13702
13790
  utils_default.forEachEntry(formData, (name, value) => {
13703
13791
  buildPath(parsePropPath(name), value, obj, 0);
13704
13792
  });
13705
- return obj;
13793
+ return normalizeArrays(obj);
13706
13794
  }
13707
13795
  return null;
13708
13796
  }
@@ -14044,16 +14132,16 @@ var import_https_proxy_agent = __toESM(require_dist());
14044
14132
  var import_follow_redirects = __toESM(require_follow_redirects());
14045
14133
 
14046
14134
  // ../node_modules/axios/lib/env/data.js
14047
- var VERSION = "1.20.0";
14135
+ var VERSION = "1.21.0";
14048
14136
 
14049
14137
  // ../node_modules/axios/lib/helpers/parseProtocol.js
14050
14138
  function parseProtocol(url2) {
14051
14139
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url2);
14052
- return match && match[1] || "";
14140
+ return match && match[1].toLowerCase() || "";
14053
14141
  }
14054
14142
 
14055
14143
  // ../node_modules/axios/lib/helpers/fromDataURI.js
14056
- var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
14144
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/i;
14057
14145
  function fromDataURI(uri, asBlob, options) {
14058
14146
  const _Blob = options && options.Blob || platform_default.classes.Blob;
14059
14147
  const protocol = parseProtocol(uri);
@@ -14076,7 +14164,10 @@ function fromDataURI(uri, asBlob, options) {
14076
14164
  } else if (params) {
14077
14165
  mime = "text/plain" + params;
14078
14166
  }
14079
- const buffer = encoding === "base64" ? Buffer.from(body, "base64") : Buffer.from(decodeURIComponent(body), encoding);
14167
+ const buffer = encoding === "base64" ? Buffer.from(
14168
+ body.replace(/%([\da-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))),
14169
+ "base64"
14170
+ ) : Buffer.from(decodeURIComponent(body), encoding);
14080
14171
  if (asBlob) {
14081
14172
  if (!_Blob) {
14082
14173
  throw new AxiosError_default("Blob is not supported", AxiosError_default.ERR_NOT_SUPPORT);
@@ -14156,7 +14247,10 @@ var AxiosTransformStream = class extends stream3__default.default.Transform {
14156
14247
  const timeWindow = internals.timeWindow;
14157
14248
  const divider = 1e3 / timeWindow;
14158
14249
  const bytesThreshold = maxRate / divider;
14159
- const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
14250
+ let minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
14251
+ if (maxRate) {
14252
+ minChunkSize = Math.min(bytesThreshold, minChunkSize);
14253
+ }
14160
14254
  const pushChunk = (_chunk, _callback) => {
14161
14255
  const bytes = Buffer.byteLength(_chunk);
14162
14256
  internals.bytesSeen += bytes;
@@ -14172,6 +14266,9 @@ var AxiosTransformStream = class extends stream3__default.default.Transform {
14172
14266
  }
14173
14267
  };
14174
14268
  const transformChunk = (_chunk, _callback) => {
14269
+ if (this.destroyed) {
14270
+ return _callback();
14271
+ }
14175
14272
  const chunkSize = Buffer.byteLength(_chunk);
14176
14273
  let chunkRemainder = null;
14177
14274
  let maxChunkSize = readableHighWaterMark;
@@ -14194,7 +14291,7 @@ var AxiosTransformStream = class extends stream3__default.default.Transform {
14194
14291
  }, timeWindow - passed);
14195
14292
  }
14196
14293
  if (bytesLeft < maxChunkSize) {
14197
- maxChunkSize = bytesLeft;
14294
+ maxChunkSize = Math.max(1, Math.floor(bytesLeft));
14198
14295
  }
14199
14296
  }
14200
14297
  if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
@@ -14245,9 +14342,9 @@ var CRLF_BYTES = textEncoder.encode(CRLF);
14245
14342
  var CRLF_BYTES_COUNT = 2;
14246
14343
  var FormDataPart = class {
14247
14344
  constructor(name, value) {
14248
- const { escapeName } = this.constructor;
14345
+ const { escapeName: escapeName2 } = this.constructor;
14249
14346
  const isStringValue = utils_default.isString(value);
14250
- let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ""}${CRLF}`;
14347
+ let headers = `Content-Disposition: form-data; name="${escapeName2(name)}"${!isStringValue && value.name ? `; filename="${escapeName2(value.name)}"` : ""}${CRLF}`;
14251
14348
  if (isStringValue) {
14252
14349
  value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
14253
14350
  } else {
@@ -14401,7 +14498,7 @@ var Http2Sessions = class {
14401
14498
  timer = null;
14402
14499
  }
14403
14500
  stream4.once("close", () => {
14404
- if (!--streamsCount) {
14501
+ if (!--streamsCount && !removed) {
14405
14502
  timer = setTimeout(() => {
14406
14503
  timer = null;
14407
14504
  removeSession();
@@ -14413,6 +14510,7 @@ var Http2Sessions = class {
14413
14510
  }
14414
14511
  session.once("close", removeSession);
14415
14512
  session.once("error", removeSession);
14513
+ session.once("goaway", removeSession);
14416
14514
  let entry = [session, options];
14417
14515
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
14418
14516
  return session;
@@ -14434,8 +14532,6 @@ var callbackify = (fn, reducer) => {
14434
14532
  } : fn;
14435
14533
  };
14436
14534
  var callbackify_default = callbackify;
14437
-
14438
- // ../node_modules/axios/lib/helpers/shouldBypassProxy.js
14439
14535
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
14440
14536
  var trimTrailingDots = (value) => {
14441
14537
  let end = value.length;
@@ -14629,7 +14725,20 @@ var normalizeNoProxyHost = (hostname) => {
14629
14725
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
14630
14726
  hostname = hostname.slice(1, -1);
14631
14727
  }
14632
- const trimmed = trimTrailingDots(hostname);
14728
+ let trimmed = trimTrailingDots(hostname);
14729
+ if (trimmed.indexOf(":") !== -1) {
14730
+ try {
14731
+ trimmed = new URL("http://[" + trimmed + "]/").hostname.slice(1, -1);
14732
+ } catch (_err) {
14733
+ return trimmed;
14734
+ }
14735
+ } else if (/[\u0080-\uffff]/.test(trimmed)) {
14736
+ const prefix = /^[*.]+/.exec(trimmed);
14737
+ const start = prefix ? prefix[0] : "";
14738
+ const ascii = url.domainToASCII(trimmed.slice(start.length));
14739
+ if (!ascii) return "";
14740
+ trimmed = start + trimTrailingDots(ascii);
14741
+ }
14633
14742
  const ipv4 = normalizeIPAddress(trimmed);
14634
14743
  if (ipv4 !== trimmed) {
14635
14744
  return ipv4;
@@ -14900,6 +15009,26 @@ var estimateBase64BufferAllocation = (body) => {
14900
15009
  }
14901
15010
  return Math.floor((len - padding) * 3 / 4);
14902
15011
  };
15012
+ var estimatePercentDecodedBase64BufferAllocation = (body) => {
15013
+ if (body.indexOf("%") === -1) {
15014
+ return estimateBase64BufferAllocation(body);
15015
+ }
15016
+ let length = 0;
15017
+ let previous = 0;
15018
+ let last = 0;
15019
+ for (let i = 0, len = body.length; i < len; i++) {
15020
+ let code = body.charCodeAt(i);
15021
+ if (code === 37 && isPercentEncodedByte(body, i, len)) {
15022
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
15023
+ i += 2;
15024
+ }
15025
+ length++;
15026
+ previous = last;
15027
+ last = code;
15028
+ }
15029
+ const padding = last === 61 ? previous === 61 ? 2 : 1 : 0;
15030
+ return Math.floor((length - padding) * 3 / 4);
15031
+ };
14903
15032
  var estimatePercentDecodedBase64Bytes = (body) => {
14904
15033
  const len = body.length;
14905
15034
  let significant = 0;
@@ -14929,14 +15058,14 @@ var estimatePercentDecodedBase64Bytes = (body) => {
14929
15058
  }
14930
15059
  return base64Bytes(significant);
14931
15060
  };
14932
- var estimateDataURLBytes = (url2, estimateBase64) => {
15061
+ var estimateDataURLBytes = (url2, estimateBase64, base64Pattern) => {
14933
15062
  if (!url2 || typeof url2 !== "string") return 0;
14934
- if (!url2.startsWith("data:")) return 0;
15063
+ if (!/^data:/i.test(url2)) return 0;
14935
15064
  const comma = url2.indexOf(",");
14936
15065
  if (comma < 0) return 0;
14937
15066
  const meta = url2.slice(5, comma);
14938
15067
  const body = url2.slice(comma + 1);
14939
- const isBase64 = /;base64/i.test(meta);
15068
+ const isBase64 = base64Pattern.test(meta);
14940
15069
  if (isBase64) {
14941
15070
  return estimateBase64(body);
14942
15071
  }
@@ -14968,11 +15097,12 @@ function estimateDataURLDecodedBytes(url2) {
14968
15097
  const fragmentIndex = typeof url2 === "string" ? url2.indexOf("#") : -1;
14969
15098
  return estimateDataURLBytes(
14970
15099
  fragmentIndex === -1 ? url2 : url2.slice(0, fragmentIndex),
14971
- estimatePercentDecodedBase64Bytes
15100
+ estimatePercentDecodedBase64Bytes,
15101
+ /; *base64[\t\n\f\r ]*$/i
14972
15102
  );
14973
15103
  }
14974
15104
  function estimateDataURLBufferAllocation(url2) {
14975
- return estimateDataURLBytes(url2, estimateBase64BufferAllocation);
15105
+ return estimateDataURLBytes(url2, estimatePercentDecodedBase64BufferAllocation, /;base64$/i);
14976
15106
  }
14977
15107
 
14978
15108
  // ../node_modules/axios/lib/adapters/http.js
@@ -15006,6 +15136,18 @@ function handleSocketError(err) {
15006
15136
  var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
15007
15137
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
15008
15138
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
15139
+ var directAgents = /* @__PURE__ */ new WeakMap();
15140
+ var directAgentHooks = ["createConnection", "getName"];
15141
+ var nativeAgentPoolHooks = [
15142
+ "addRequest",
15143
+ "createSocket",
15144
+ "removeSocket",
15145
+ "keepSocketAlive",
15146
+ "reuseSocket",
15147
+ "_getSession",
15148
+ "_cacheSession",
15149
+ "_evictSession"
15150
+ ];
15009
15151
  var NODE_NATIVE_ENV_PROXY_SUPPORT = {
15010
15152
  22: 21,
15011
15153
  24: 5
@@ -15035,6 +15177,49 @@ function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.
15035
15177
  function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
15036
15178
  return isHttps.test(options.protocol) ? configHttpsAgent || https__default.default.globalAgent : configHttpAgent || http__default.default.globalAgent;
15037
15179
  }
15180
+ function getDirectAgent(configuredAgent, transport) {
15181
+ if (!process.allowedNodeEnvironmentFlags || !process.allowedNodeEnvironmentFlags.has("--use-env-proxy")) {
15182
+ return configuredAgent;
15183
+ }
15184
+ const agent = configuredAgent || transport.globalAgent;
15185
+ const options = agent && agent.options;
15186
+ if (!(agent instanceof transport.Agent) || agent.protocol !== transport.globalAgent.protocol || !options || !utils_default.hasOwnProp(options, "proxyEnv") || typeof options.proxyEnv !== "object" || options.proxyEnv === null) {
15187
+ return configuredAgent;
15188
+ }
15189
+ for (const hook of nativeAgentPoolHooks) {
15190
+ if (utils_default.isFunction(transport.Agent.prototype[hook]) && agent[hook] !== transport.Agent.prototype[hook]) {
15191
+ throw new AxiosError_default(
15192
+ "proxy: false cannot adapt an agent overriding " + hook + "; use an agent constructed without proxyEnv",
15193
+ AxiosError_default.ERR_BAD_OPTION_VALUE
15194
+ );
15195
+ }
15196
+ }
15197
+ let direct = directAgents.get(agent);
15198
+ if (!direct) {
15199
+ direct = new transport.Agent({ ...options, proxyEnv: void 0 });
15200
+ const destroy = agent.destroy;
15201
+ agent.destroy = function destroyWithDirectAgent() {
15202
+ try {
15203
+ return destroy.apply(this, arguments);
15204
+ } finally {
15205
+ direct.destroy();
15206
+ }
15207
+ };
15208
+ directAgents.set(agent, direct);
15209
+ }
15210
+ for (const hook of directAgentHooks) {
15211
+ direct[hook] = agent[hook] === transport.Agent.prototype[hook] ? transport.Agent.prototype[hook] : bind(agent[hook], agent);
15212
+ }
15213
+ return direct;
15214
+ }
15215
+ function setDirectAgent(options, configHttpAgent, configHttpsAgent) {
15216
+ const secure = isHttps.test(options.protocol);
15217
+ const agent = getDirectAgent(secure ? configHttpsAgent : configHttpAgent, secure ? https__default.default : http__default.default);
15218
+ options.agent = agent;
15219
+ if (options.agents) {
15220
+ options.agents[secure ? "https" : "http"] = agent;
15221
+ }
15222
+ }
15038
15223
  function getTunnelingAgent(agentOptions, userHttpsAgent) {
15039
15224
  const key = agentOptions.protocol + "//" + agentOptions.hostname + ":" + (agentOptions.port || "") + "#" + (agentOptions.auth || "");
15040
15225
  const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, /* @__PURE__ */ new Map()).get(userHttpsAgent) : tunnelingAgentCache;
@@ -15042,13 +15227,12 @@ function getTunnelingAgent(agentOptions, userHttpsAgent) {
15042
15227
  if (agent) return agent;
15043
15228
  const merged = userHttpsAgent && userHttpsAgent.options ? { ...userHttpsAgent.options, ...agentOptions } : agentOptions;
15044
15229
  agent = new import_https_proxy_agent.default(merged);
15045
- if (userHttpsAgent && userHttpsAgent.options) {
15046
- const originTLSOptions = { ...userHttpsAgent.options };
15047
- const callback = agent.callback;
15048
- agent.callback = function axiosTunnelingAgentCallback(req, opts) {
15049
- return callback.call(this, req, { ...originTLSOptions, ...opts });
15050
- };
15051
- }
15230
+ const callback = agent.callback;
15231
+ agent.callback = function axiosTunnelingAgentCallback(req, opts) {
15232
+ const originTLSAgent = userHttpsAgent || https__default.default.globalAgent;
15233
+ const originTLSOptions = originTLSAgent && originTLSAgent.options;
15234
+ return callback.call(this, req, { ...originTLSOptions, ...opts });
15235
+ };
15052
15236
  agent[kAxiosInstalledTunnel] = true;
15053
15237
  cache.set(key, agent);
15054
15238
  return agent;
@@ -15072,6 +15256,10 @@ var flushOnFinish = (stream4, [throttled, flush]) => {
15072
15256
  };
15073
15257
  var http2Sessions = new Http2Sessions_default();
15074
15258
  function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
15259
+ if (!isSameOriginRedirect(options, requestDetails)) {
15260
+ stripMatchingHeaders(options.headers, /* @__PURE__ */ new Set(["authorization", "cookie"]));
15261
+ delete options.auth;
15262
+ }
15075
15263
  if (options.beforeRedirects.proxy) {
15076
15264
  options.beforeRedirects.proxy(options);
15077
15265
  }
@@ -15081,6 +15269,9 @@ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
15081
15269
  if (options.beforeRedirects.sensitiveHeaders) {
15082
15270
  options.beforeRedirects.sensitiveHeaders(options, requestDetails);
15083
15271
  }
15272
+ if (options.beforeRedirects.direct) {
15273
+ options.beforeRedirects.direct(options);
15274
+ }
15084
15275
  if (options.beforeRedirects.config) {
15085
15276
  options.beforeRedirects.config(options, responseDetails, requestDetails);
15086
15277
  }
@@ -15126,6 +15317,9 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
15126
15317
  if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
15127
15318
  options.agent = void 0;
15128
15319
  }
15320
+ if (isRedirect && options.agents && options.agents.https && options.agents.https[kAxiosInstalledTunnel]) {
15321
+ options.agents.https = configHttpsAgent;
15322
+ }
15129
15323
  if (proxy) {
15130
15324
  const isProxyURL = proxy instanceof URL;
15131
15325
  const readProxyField = (key) => isProxyURL || utils_default.hasOwnProp(proxy, key) ? proxy[key] : void 0;
@@ -15306,9 +15500,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15306
15500
  if (httpVersion === void 0) httpVersion = 1;
15307
15501
  const rawHttpVersion = httpVersion;
15308
15502
  let http2Options = own2("http2Options");
15503
+ const configProxy = own2("proxy");
15309
15504
  const httpAgent = own2("httpAgent");
15310
15505
  const httpsAgent = own2("httpsAgent");
15311
- const configProxy = own2("proxy");
15312
15506
  const responseType = own2("responseType");
15313
15507
  const responseEncoding = own2("responseEncoding");
15314
15508
  const socketPath = own2("socketPath");
@@ -15447,6 +15641,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15447
15641
  } catch (err) {
15448
15642
  throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config);
15449
15643
  }
15644
+ if (maxContentLength > -1 && (responseType === "blob" ? convertedData.size : convertedData.length) > maxContentLength) {
15645
+ return reject(
15646
+ new AxiosError_default(
15647
+ "maxContentLength size of " + maxContentLength + " exceeded",
15648
+ AxiosError_default.ERR_BAD_RESPONSE,
15649
+ config
15650
+ )
15651
+ );
15652
+ }
15450
15653
  if (responseType === "text") {
15451
15654
  convertedData = convertedData.toString(responseEncoding);
15452
15655
  if (!responseEncoding || responseEncoding === "utf8") {
@@ -15648,9 +15851,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15648
15851
  }
15649
15852
  let transport;
15650
15853
  let isNativeTransport = false;
15651
- let transportEnforcesMaxBodyLength = false;
15652
15854
  const isHttpsRequest = isHttps.test(options.protocol);
15653
- if (options.agent == null) {
15855
+ if (!isHttp2 && configProxy === false) {
15856
+ setDirectAgent(options, httpAgent, httpsAgent);
15857
+ options.beforeRedirects.direct = (redirectOptions) => {
15858
+ setDirectAgent(redirectOptions, httpAgent, httpsAgent);
15859
+ };
15860
+ } else if (options.agent == null) {
15654
15861
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
15655
15862
  }
15656
15863
  if (isHttp2) {
@@ -15672,7 +15879,6 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15672
15879
  transport = isHttpsRequest ? https__default.default : http__default.default;
15673
15880
  isNativeTransport = true;
15674
15881
  } else {
15675
- transportEnforcesMaxBodyLength = true;
15676
15882
  options.sensitiveHeaders = [];
15677
15883
  if (maxRedirects) {
15678
15884
  options.maxRedirects = maxRedirects;
@@ -15958,7 +16164,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15958
16164
  }
15959
16165
  });
15960
16166
  let uploadStream = data;
15961
- if (maxBodyLength > -1 && !transportEnforcesMaxBodyLength) {
16167
+ if (maxBodyLength > -1) {
15962
16168
  const limit = maxBodyLength;
15963
16169
  let bytesSent = 0;
15964
16170
  uploadStream = stream3__default.default.pipeline(
@@ -15995,16 +16201,14 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
15995
16201
  });
15996
16202
  };
15997
16203
 
15998
- // ../node_modules/axios/lib/helpers/isURLSameOrigin.js
15999
- var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url2) => {
16000
- url2 = new URL(url2, platform_default.origin);
16001
- return origin2.protocol === url2.protocol && origin2.host === url2.host && (isMSIE || origin2.port === url2.port);
16002
- })(
16003
- new URL(platform_default.origin),
16004
- platform_default.navigator && /(msie|trident)/i.test(platform_default.navigator.userAgent)
16005
- ) : () => true;
16006
-
16007
16204
  // ../node_modules/axios/lib/helpers/cookies.js
16205
+ var decodeCookieValue = (value) => {
16206
+ try {
16207
+ return decodeURIComponent(value);
16208
+ } catch (e) {
16209
+ return value;
16210
+ }
16211
+ };
16008
16212
  var cookies_default = platform_default.hasStandardBrowserEnv ? (
16009
16213
  // Standard browser envs support document.cookie
16010
16214
  {
@@ -16030,20 +16234,29 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
16030
16234
  },
16031
16235
  read(name) {
16032
16236
  if (typeof document === "undefined") return null;
16033
- const cookies = document.cookie.split(";");
16237
+ const cookieString = document.cookie;
16238
+ if (!cookieString) return null;
16239
+ const cookies = cookieString.split(";");
16034
16240
  for (let i = 0; i < cookies.length; i++) {
16035
16241
  const cookie = cookies[i].replace(/^\s+/, "");
16036
16242
  const eq = cookie.indexOf("=");
16037
16243
  if (eq !== -1 && cookie.slice(0, eq) === name) {
16038
- try {
16039
- return decodeURIComponent(cookie.slice(eq + 1));
16040
- } catch (e) {
16041
- return cookie.slice(eq + 1);
16042
- }
16244
+ return decodeCookieValue(cookie.slice(eq + 1));
16043
16245
  }
16044
16246
  }
16045
16247
  return null;
16046
16248
  },
16249
+ async readAsync(name) {
16250
+ try {
16251
+ const store = typeof window !== "undefined" && window.cookieStore;
16252
+ if (store && utils_default.isFunction(store.get)) {
16253
+ const cookie = await store.get(name);
16254
+ return cookie ? decodeCookieValue(cookie.value) : null;
16255
+ }
16256
+ } catch (e) {
16257
+ }
16258
+ return this.read(name);
16259
+ },
16047
16260
  remove(name) {
16048
16261
  this.write(name, "", Date.now() - 864e5, "/");
16049
16262
  }
@@ -16056,130 +16269,224 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
16056
16269
  read() {
16057
16270
  return null;
16058
16271
  },
16272
+ async readAsync() {
16273
+ return null;
16274
+ },
16059
16275
  remove() {
16060
16276
  }
16061
16277
  }
16062
16278
  );
16063
16279
 
16280
+ // ../node_modules/axios/lib/helpers/isURLSameOrigin.js
16281
+ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2) => (url2) => {
16282
+ url2 = new URL(url2, document.baseURI || platform_default.origin);
16283
+ return origin2.protocol === url2.protocol && origin2.host === url2.host && origin2.port === url2.port;
16284
+ })(new URL(platform_default.origin)) : () => true;
16285
+
16286
+ // ../node_modules/axios/lib/core/assertParamsAcyclic.js
16287
+ function assertParamsAcyclic(params) {
16288
+ const pending = [{ value: params }];
16289
+ const active = /* @__PURE__ */ new WeakSet();
16290
+ const visited = /* @__PURE__ */ new WeakSet();
16291
+ while (pending.length) {
16292
+ const { value, done } = pending.pop();
16293
+ if (!utils_default.isPlainObject(value) && !utils_default.isArray(value)) continue;
16294
+ if (done) {
16295
+ active.delete(value);
16296
+ continue;
16297
+ }
16298
+ if (active.has(value)) {
16299
+ throw new AxiosError_default(
16300
+ "Circular reference detected in params",
16301
+ AxiosError_default.ERR_BAD_OPTION_VALUE
16302
+ );
16303
+ }
16304
+ if (visited.has(value)) continue;
16305
+ visited.add(value);
16306
+ active.add(value);
16307
+ pending.push({ value, done: true });
16308
+ const keys = Object.keys(value);
16309
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
16310
+ Object.getOwnPropertySymbols(value).forEach((key) => {
16311
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
16312
+ if (descriptor && descriptor.enumerable) keys.push(key);
16313
+ });
16314
+ }
16315
+ keys.forEach((key) => {
16316
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
16317
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
16318
+ if (descriptor && utils_default.hasOwnProp(descriptor, "value")) {
16319
+ pending.push({ value: descriptor.value });
16320
+ }
16321
+ } else {
16322
+ pending.push({ value: value[key] });
16323
+ }
16324
+ });
16325
+ }
16326
+ }
16327
+
16064
16328
  // ../node_modules/axios/lib/core/mergeConfig.js
16065
16329
  var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
16066
16330
  var ownEnumerableKeys = (thing) => {
16067
16331
  if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
16068
16332
  return Object.keys(thing).concat(
16069
- Object.getOwnPropertySymbols(thing).filter(
16070
- (symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
16071
- )
16333
+ Object.getOwnPropertySymbols(thing).filter((symbol) => {
16334
+ const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
16335
+ return descriptor && descriptor.enumerable;
16336
+ })
16072
16337
  );
16073
16338
  }
16074
16339
  return Object.keys(thing);
16075
16340
  };
16076
- function mergeConfig(config1, config2) {
16077
- config1 = config1 || {};
16078
- config2 = config2 || {};
16079
- const config = /* @__PURE__ */ Object.create(null);
16080
- Object.defineProperty(config, "hasOwnProperty", {
16081
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
16082
- // this data descriptor into an accessor descriptor on the way in.
16083
- __proto__: null,
16084
- value: Object.prototype.hasOwnProperty,
16085
- enumerable: false,
16086
- writable: true,
16087
- configurable: true
16088
- });
16089
- function getMergedValue(target, source, prop, caseless) {
16090
- if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
16091
- return utils_default.merge.call({ caseless }, target, source);
16092
- } else if (utils_default.isPlainObject(source)) {
16093
- return utils_default.merge({}, source);
16094
- } else if (utils_default.isArray(source)) {
16095
- return source.slice();
16096
- }
16097
- return source;
16341
+ function mergeParams(a, b) {
16342
+ const pending = [];
16343
+ const copies = /* @__PURE__ */ new WeakMap();
16344
+ const empty = {};
16345
+ function copy(target, source) {
16346
+ if (!utils_default.isPlainObject(source)) {
16347
+ return utils_default.isArray(source) ? source.slice() : source;
16348
+ }
16349
+ const base = utils_default.isPlainObject(target) ? target : empty;
16350
+ let bases = copies.get(source);
16351
+ if (!bases) {
16352
+ bases = /* @__PURE__ */ new WeakMap();
16353
+ copies.set(source, bases);
16354
+ }
16355
+ if (bases.has(base)) return bases.get(base);
16356
+ const result2 = {};
16357
+ bases.set(base, result2);
16358
+ pending.push({ base, source, result: result2 });
16359
+ return result2;
16360
+ }
16361
+ const result = utils_default.isUndefined(b) ? copy(void 0, a) : copy(a, b);
16362
+ while (pending.length) {
16363
+ const { base, source, result: target } = pending.pop();
16364
+ const baseKeys = new Set(ownEnumerableKeys(base));
16365
+ const sourceKeys = new Set(ownEnumerableKeys(source));
16366
+ const keys = /* @__PURE__ */ new Set([...baseKeys, ...sourceKeys]);
16367
+ keys.forEach((key) => {
16368
+ if (key === "__proto__" || key === "constructor" || key === "prototype") return;
16369
+ const hasSource = sourceKeys.has(key);
16370
+ const value = hasSource ? source[key] : void 0;
16371
+ const previous = (!hasSource || utils_default.isPlainObject(value)) && baseKeys.has(key) ? base[key] : void 0;
16372
+ target[key] = hasSource ? copy(previous, value) : copy(void 0, previous);
16373
+ });
16098
16374
  }
16099
- function mergeDeepProperties(a, b, prop, caseless) {
16100
- if (!utils_default.isUndefined(b)) {
16101
- return getMergedValue(a, b, prop, caseless);
16102
- } else if (!utils_default.isUndefined(a)) {
16103
- return getMergedValue(void 0, a, prop, caseless);
16104
- }
16375
+ assertParamsAcyclic(result);
16376
+ return result;
16377
+ }
16378
+ function getMergedValue(target, source, prop, caseless) {
16379
+ if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
16380
+ return utils_default.merge.call({ caseless }, target, source);
16381
+ } else if (utils_default.isPlainObject(source)) {
16382
+ return utils_default.merge({}, source);
16383
+ } else if (utils_default.isArray(source)) {
16384
+ return source.slice();
16385
+ }
16386
+ return source;
16387
+ }
16388
+ function mergeDeepProperties(a, b, prop, caseless) {
16389
+ if (!utils_default.isUndefined(b)) {
16390
+ return getMergedValue(a, b, prop, caseless);
16391
+ } else if (!utils_default.isUndefined(a)) {
16392
+ return getMergedValue(void 0, a, prop, caseless);
16105
16393
  }
16106
- function valueFromConfig2(a, b) {
16107
- if (!utils_default.isUndefined(b)) {
16108
- return getMergedValue(void 0, b);
16109
- }
16394
+ }
16395
+ function valueFromConfig2(a, b) {
16396
+ if (!utils_default.isUndefined(b)) {
16397
+ return getMergedValue(void 0, b);
16110
16398
  }
16111
- function defaultToConfig2(a, b) {
16112
- if (!utils_default.isUndefined(b)) {
16113
- return getMergedValue(void 0, b);
16114
- } else if (!utils_default.isUndefined(a)) {
16115
- return getMergedValue(void 0, a);
16116
- }
16399
+ }
16400
+ function defaultToConfig2(a, b) {
16401
+ if (!utils_default.isUndefined(b)) {
16402
+ return getMergedValue(void 0, b);
16403
+ } else if (!utils_default.isUndefined(a)) {
16404
+ return getMergedValue(void 0, a);
16117
16405
  }
16118
- function getMergedTransitionalOption(prop) {
16119
- const transitional2 = utils_default.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
16120
- if (!utils_default.isUndefined(transitional2)) {
16121
- if (utils_default.isPlainObject(transitional2)) {
16122
- if (utils_default.hasOwnProp(transitional2, prop)) {
16123
- return transitional2[prop];
16124
- }
16125
- } else {
16126
- return void 0;
16406
+ }
16407
+ function getMergedTransitionalOption(config1, config2, prop) {
16408
+ const transitional2 = utils_default.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
16409
+ if (!utils_default.isUndefined(transitional2)) {
16410
+ if (utils_default.isPlainObject(transitional2)) {
16411
+ if (utils_default.hasOwnProp(transitional2, prop)) {
16412
+ return transitional2[prop];
16127
16413
  }
16414
+ } else {
16415
+ return void 0;
16128
16416
  }
16129
- const transitional1 = utils_default.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
16130
- if (utils_default.isPlainObject(transitional1) && utils_default.hasOwnProp(transitional1, prop)) {
16131
- return transitional1[prop];
16132
- }
16133
- return void 0;
16134
16417
  }
16135
- function mergeDirectKeys(a, b, prop) {
16136
- if (utils_default.hasOwnProp(config2, prop)) {
16137
- return getMergedValue(a, b);
16138
- } else if (utils_default.hasOwnProp(config1, prop)) {
16139
- return getMergedValue(void 0, a);
16140
- }
16141
- }
16142
- const mergeMap = {
16143
- url: valueFromConfig2,
16144
- method: valueFromConfig2,
16145
- data: valueFromConfig2,
16146
- baseURL: defaultToConfig2,
16147
- transformRequest: defaultToConfig2,
16148
- transformResponse: defaultToConfig2,
16149
- paramsSerializer: defaultToConfig2,
16150
- timeout: defaultToConfig2,
16151
- timeoutErrorMessage: defaultToConfig2,
16152
- withCredentials: defaultToConfig2,
16153
- withXSRFToken: defaultToConfig2,
16154
- adapter: defaultToConfig2,
16155
- responseType: defaultToConfig2,
16156
- xsrfCookieName: defaultToConfig2,
16157
- xsrfHeaderName: defaultToConfig2,
16158
- onUploadProgress: defaultToConfig2,
16159
- onDownloadProgress: defaultToConfig2,
16160
- decompress: defaultToConfig2,
16161
- maxContentLength: defaultToConfig2,
16162
- maxBodyLength: defaultToConfig2,
16163
- beforeRedirect: defaultToConfig2,
16164
- transport: defaultToConfig2,
16165
- httpAgent: defaultToConfig2,
16166
- httpsAgent: defaultToConfig2,
16167
- cancelToken: defaultToConfig2,
16168
- socketPath: defaultToConfig2,
16169
- allowedSocketPaths: defaultToConfig2,
16170
- responseEncoding: defaultToConfig2,
16171
- validateStatus: mergeDirectKeys,
16172
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
16173
- };
16174
- utils_default.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
16175
- if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
16418
+ const transitional1 = utils_default.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
16419
+ if (utils_default.isPlainObject(transitional1) && utils_default.hasOwnProp(transitional1, prop)) {
16420
+ return transitional1[prop];
16421
+ }
16422
+ return void 0;
16423
+ }
16424
+ function mergeDirectKeys(a, b, prop, config1, config2) {
16425
+ if (utils_default.hasOwnProp(config2, prop)) {
16426
+ return getMergedValue(a, b);
16427
+ } else if (utils_default.hasOwnProp(config1, prop)) {
16428
+ return getMergedValue(void 0, a);
16429
+ }
16430
+ }
16431
+ function mergeHeaders(a, b, prop) {
16432
+ return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
16433
+ }
16434
+ var hasOwnPropertyDescriptor = Object.freeze({
16435
+ __proto__: null,
16436
+ value: Object.prototype.hasOwnProperty,
16437
+ enumerable: false,
16438
+ writable: true,
16439
+ configurable: true
16440
+ });
16441
+ var mergeMap = {
16442
+ url: valueFromConfig2,
16443
+ method: valueFromConfig2,
16444
+ data: valueFromConfig2,
16445
+ baseURL: defaultToConfig2,
16446
+ transformRequest: defaultToConfig2,
16447
+ transformResponse: defaultToConfig2,
16448
+ params: mergeParams,
16449
+ paramsSerializer: defaultToConfig2,
16450
+ timeout: defaultToConfig2,
16451
+ timeoutErrorMessage: defaultToConfig2,
16452
+ withCredentials: defaultToConfig2,
16453
+ withXSRFToken: defaultToConfig2,
16454
+ adapter: defaultToConfig2,
16455
+ responseType: defaultToConfig2,
16456
+ xsrfCookieName: defaultToConfig2,
16457
+ xsrfHeaderName: defaultToConfig2,
16458
+ onUploadProgress: defaultToConfig2,
16459
+ onDownloadProgress: defaultToConfig2,
16460
+ decompress: defaultToConfig2,
16461
+ maxContentLength: defaultToConfig2,
16462
+ maxBodyLength: defaultToConfig2,
16463
+ beforeRedirect: defaultToConfig2,
16464
+ transport: defaultToConfig2,
16465
+ httpAgent: defaultToConfig2,
16466
+ httpsAgent: defaultToConfig2,
16467
+ cancelToken: defaultToConfig2,
16468
+ socketPath: defaultToConfig2,
16469
+ allowedSocketPaths: defaultToConfig2,
16470
+ responseEncoding: defaultToConfig2,
16471
+ validateStatus: mergeDirectKeys,
16472
+ headers: mergeHeaders
16473
+ };
16474
+ function mergeConfig(config1, config2) {
16475
+ config1 = config1 || {};
16476
+ config2 = config2 || {};
16477
+ const config = /* @__PURE__ */ Object.create(null);
16478
+ Object.defineProperty(config, "hasOwnProperty", hasOwnPropertyDescriptor);
16479
+ const keys = ownEnumerableKeys({ ...config1, ...config2 });
16480
+ for (let i = 0, len = keys.length; i < len; i++) {
16481
+ const prop = keys[i];
16482
+ if (prop === "__proto__" || prop === "constructor" || prop === "prototype") continue;
16176
16483
  const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
16177
16484
  const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
16178
16485
  const b = utils_default.hasOwnProp(config2, prop) ? config2[prop] : void 0;
16179
- const configValue = merge2(a, b, prop);
16486
+ const configValue = merge2 === mergeDirectKeys ? merge2(a, b, prop, config1, config2) : merge2(a, b, prop);
16180
16487
  utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
16181
- });
16182
- if (utils_default.hasOwnProp(config2, "validateStatus") && utils_default.isUndefined(config2.validateStatus) && getMergedTransitionalOption("validateStatusUndefinedResolves") === false) {
16488
+ }
16489
+ if (utils_default.hasOwnProp(config2, "validateStatus") && utils_default.isUndefined(config2.validateStatus) && getMergedTransitionalOption(config1, config2, "validateStatusUndefinedResolves") === false) {
16183
16490
  if (utils_default.hasOwnProp(config1, "validateStatus")) {
16184
16491
  config.validateStatus = getMergedValue(void 0, config1.validateStatus);
16185
16492
  } else {
@@ -16194,7 +16501,8 @@ var encodeUTF8 = (str) => encodeURIComponent(str).replace(
16194
16501
  /%([0-9A-F]{2})/gi,
16195
16502
  (_, hex) => String.fromCharCode(parseInt(hex, 16))
16196
16503
  );
16197
- function resolveConfig(config) {
16504
+ var readCookie = (name) => cookies_default.read(name);
16505
+ function resolveConfig(config, readXsrfCookie = readCookie) {
16198
16506
  const newConfig = mergeConfig({}, config);
16199
16507
  const own2 = (key) => utils_default.hasOwnProp(newConfig, key) ? newConfig[key] : void 0;
16200
16508
  const data = own2("data");
@@ -16215,10 +16523,15 @@ function resolveConfig(config) {
16215
16523
  if (auth) {
16216
16524
  const username = utils_default.getSafeProp(auth, "username") || "";
16217
16525
  const password = utils_default.getSafeProp(auth, "password") || "";
16526
+ const transitional2 = own2("transitional");
16527
+ const encodeUsername = transitional2 && utils_default.hasOwnProp(transitional2, "encodeBasicAuthUsername") && transitional2.encodeBasicAuthUsername === true;
16218
16528
  try {
16219
16529
  headers.set(
16220
16530
  "Authorization",
16221
- "Basic " + btoa(username + ":" + (password ? encodeUTF8(password) : ""))
16531
+ // Preserve legacy username bytes unless the caller opts in to UTF-8.
16532
+ "Basic " + btoa(
16533
+ (encodeUsername ? encodeUTF8(username) : username) + ":" + (password ? encodeUTF8(password) : "")
16534
+ )
16222
16535
  );
16223
16536
  } catch (e) {
16224
16537
  throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_OPTION_VALUE, config);
@@ -16238,7 +16551,7 @@ function resolveConfig(config) {
16238
16551
  }
16239
16552
  const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin_default(newConfig.url);
16240
16553
  if (shouldSendXSRF) {
16241
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
16554
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
16242
16555
  if (xsrfValue) {
16243
16556
  headers.set(xsrfHeaderName, xsrfValue);
16244
16557
  }
@@ -16252,16 +16565,50 @@ var resolveConfig_default = resolveConfig;
16252
16565
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
16253
16566
  var xhr_default = isXHRAdapterSupported && function(config) {
16254
16567
  return new Promise(function dispatchXhrRequest(resolve, reject) {
16255
- const _config = resolveConfig_default(config);
16568
+ let useAsyncXsrf;
16569
+ try {
16570
+ const store = platform_default.hasStandardBrowserEnv && typeof window !== "undefined" && window.cookieStore;
16571
+ useAsyncXsrf = store && utils_default.isFunction(store.get);
16572
+ } catch (e) {
16573
+ }
16574
+ let xsrfCookieName;
16575
+ const _config = resolveConfig_default(
16576
+ config,
16577
+ useAsyncXsrf ? (name) => {
16578
+ xsrfCookieName = name;
16579
+ return null;
16580
+ } : void 0
16581
+ );
16256
16582
  let requestData = _config.data;
16257
16583
  const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
16258
16584
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
16259
16585
  let onCanceled;
16586
+ let timeoutId;
16260
16587
  let uploadThrottled, downloadThrottled;
16261
16588
  let flushUpload, flushDownload, flushDownloadWithEvent;
16262
16589
  function done() {
16263
- flushUpload && flushUpload();
16264
- flushDownload && flushDownload();
16590
+ clearTimeout(timeoutId);
16591
+ try {
16592
+ flushUpload && flushUpload();
16593
+ } catch (err) {
16594
+ setTimeout(() => {
16595
+ throw err;
16596
+ });
16597
+ }
16598
+ try {
16599
+ flushDownload && flushDownload();
16600
+ } catch (err) {
16601
+ setTimeout(() => {
16602
+ throw err;
16603
+ });
16604
+ }
16605
+ if (request) {
16606
+ downloadThrottled && request.removeEventListener("progress", downloadThrottled);
16607
+ if (request.upload) {
16608
+ uploadThrottled && request.upload.removeEventListener("progress", uploadThrottled);
16609
+ flushUpload && request.upload.removeEventListener("loadend", flushUpload);
16610
+ }
16611
+ }
16265
16612
  _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
16266
16613
  _config.signal && _config.signal.removeEventListener("abort", onCanceled);
16267
16614
  }
@@ -16347,6 +16694,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
16347
16694
  request = null;
16348
16695
  };
16349
16696
  request.ontimeout = function handleTimeout() {
16697
+ if (!request) return;
16350
16698
  let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
16351
16699
  const transitional2 = _config.transitional || transitional_default;
16352
16700
  if (_config.timeoutErrorMessage) {
@@ -16364,11 +16712,6 @@ var xhr_default = isXHRAdapterSupported && function(config) {
16364
16712
  request = null;
16365
16713
  };
16366
16714
  requestData === void 0 && requestHeaders.setContentType(null);
16367
- if ("setRequestHeader" in request) {
16368
- utils_default.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
16369
- request.setRequestHeader(key, val);
16370
- });
16371
- }
16372
16715
  if (!utils_default.isUndefined(_config.withCredentials)) {
16373
16716
  request.withCredentials = !!_config.withCredentials;
16374
16717
  }
@@ -16393,15 +16736,18 @@ var xhr_default = isXHRAdapterSupported && function(config) {
16393
16736
  return;
16394
16737
  }
16395
16738
  reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
16396
- request.abort();
16739
+ const xhr = request;
16397
16740
  done();
16398
16741
  request = null;
16742
+ xhr.abort();
16399
16743
  };
16400
16744
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
16745
+ if (!request) return;
16401
16746
  if (_config.signal) {
16402
16747
  _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
16403
16748
  }
16404
16749
  }
16750
+ if (!request) return;
16405
16751
  const protocol = parseProtocol(_config.url);
16406
16752
  if (protocol && !platform_default.protocols.includes(protocol)) {
16407
16753
  reject(
@@ -16414,7 +16760,58 @@ var xhr_default = isXHRAdapterSupported && function(config) {
16414
16760
  done();
16415
16761
  return;
16416
16762
  }
16417
- request.send(requestData || null);
16763
+ const sendRequest = () => {
16764
+ if (!request) return;
16765
+ if ("setRequestHeader" in request) {
16766
+ utils_default.forEach(
16767
+ toByteStringHeaderObject(requestHeaders),
16768
+ function setRequestHeader(val, key) {
16769
+ request.setRequestHeader(key, val);
16770
+ }
16771
+ );
16772
+ }
16773
+ request.send(requestData || null);
16774
+ };
16775
+ if (xsrfCookieName) {
16776
+ const now = typeof performance !== "undefined" && utils_default.isFunction(performance.now) ? () => performance.now() : Date.now;
16777
+ const deadline = request.timeout > 0 ? now() + Number(request.timeout) : void 0;
16778
+ const abortOnTimeout = () => {
16779
+ if (!request) return;
16780
+ const xhr = request;
16781
+ xhr.ontimeout();
16782
+ xhr.abort();
16783
+ };
16784
+ if (deadline !== void 0) {
16785
+ const scheduleTimeout = () => {
16786
+ const remaining = deadline - now();
16787
+ if (remaining > 0) {
16788
+ timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 2147483647));
16789
+ } else {
16790
+ abortOnTimeout();
16791
+ }
16792
+ };
16793
+ scheduleTimeout();
16794
+ }
16795
+ cookies_default.readAsync(xsrfCookieName).then((value) => {
16796
+ if (!request) return;
16797
+ if (deadline !== void 0 && now() >= deadline) {
16798
+ abortOnTimeout();
16799
+ return;
16800
+ }
16801
+ if (value) {
16802
+ const headerName = utils_default.hasOwnProp(_config, "xsrfHeaderName") && _config.xsrfHeaderName;
16803
+ requestHeaders.set(headerName, value);
16804
+ }
16805
+ sendRequest();
16806
+ }).catch((error) => {
16807
+ if (!request) return;
16808
+ reject(AxiosError_default.from(error, null, config, request));
16809
+ done();
16810
+ request = null;
16811
+ });
16812
+ } else {
16813
+ sendRequest();
16814
+ }
16418
16815
  });
16419
16816
  };
16420
16817
 
@@ -16447,7 +16844,8 @@ var composeSignals = (signals, timeout) => {
16447
16844
  timer && clearTimeout(timer);
16448
16845
  timer = null;
16449
16846
  signals.forEach((signal2) => {
16450
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
16847
+ const unsubscribeSignal = utils_default.getSafeProp(signal2, "unsubscribe");
16848
+ utils_default.isFunction(unsubscribeSignal) ? unsubscribeSignal.call(signal2, onabort) : signal2.removeEventListener("abort", onabort);
16451
16849
  });
16452
16850
  signals = null;
16453
16851
  };
@@ -16547,6 +16945,110 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
16547
16945
  );
16548
16946
  };
16549
16947
 
16948
+ // ../node_modules/axios/lib/helpers/formDataToBlob.js
16949
+ var CRLF2 = "\r\n";
16950
+ var normalizeLines = (value) => String(value).replace(/\r\n|\r|\n/g, CRLF2);
16951
+ var escapeName = (value) => String(value).replace(
16952
+ /[\r\n"]/g,
16953
+ (char) => char === "\r" ? "%0D" : char === "\n" ? "%0A" : "%22"
16954
+ );
16955
+ var stringBytes = (value, normalize) => {
16956
+ let length = 0;
16957
+ for (let i = 0; i < value.length; i++) {
16958
+ const code = value.charCodeAt(i);
16959
+ if (normalize && (code === 13 || code === 10)) {
16960
+ if (code === 13 && value.charCodeAt(i + 1) === 10) i++;
16961
+ length += 2;
16962
+ } else if (code < 128) {
16963
+ length++;
16964
+ } else if (code < 2048) {
16965
+ length += 2;
16966
+ } else if (code >= 55296 && code <= 56319 && value.charCodeAt(i + 1) >= 56320 && value.charCodeAt(i + 1) <= 57343) {
16967
+ length += 4;
16968
+ i++;
16969
+ } else {
16970
+ length += 3;
16971
+ }
16972
+ }
16973
+ return length;
16974
+ };
16975
+ var FormDataError = class extends TypeError {
16976
+ constructor(message, reason) {
16977
+ super(message);
16978
+ this.name = "FormDataError";
16979
+ this.reason = reason;
16980
+ }
16981
+ };
16982
+ function formDataToBlob(form, Blob2, limit, limitError, boundary) {
16983
+ if (!utils_default.isFunction(Blob2)) {
16984
+ throw new FormDataError("Blob is not supported", "blob");
16985
+ }
16986
+ if (!utils_default.isString(boundary) || !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) || / $/.test(boundary)) {
16987
+ throw new FormDataError("Invalid multipart boundary", "boundary");
16988
+ }
16989
+ const footer = "--" + boundary + "--" + CRLF2;
16990
+ let length = footer.length;
16991
+ const parts = [];
16992
+ const checkLength = (extra) => {
16993
+ if (length + extra > limit) throw limitError();
16994
+ };
16995
+ checkLength(0);
16996
+ for (const [name, value] of form) {
16997
+ const isString2 = utils_default.isString(value);
16998
+ const valueLength = isString2 ? stringBytes(value, true) : value.size;
16999
+ if (!Number.isFinite(valueLength) || valueLength < 0) {
17000
+ throw new FormDataError("Unsupported FormData part size", "part");
17001
+ }
17002
+ checkLength(
17003
+ valueLength + stringBytes(name, true) + (!isString2 && value.name ? stringBytes(value.name, false) : 0) + (!isString2 && value.type ? stringBytes(value.type, false) : 0)
17004
+ );
17005
+ let header = "--" + boundary + CRLF2 + 'Content-Disposition: form-data; name="' + escapeName(normalizeLines(name)) + '"';
17006
+ if (!isString2) {
17007
+ header += '; filename="' + escapeName(utils_default.isString(value.name) ? value.name : "blob") + '"' + CRLF2 + "Content-Type: " + String(value.type || "application/octet-stream").replace(/[\r\n]/g, "");
17008
+ }
17009
+ header += CRLF2 + CRLF2;
17010
+ const partLength = stringBytes(header, false) + valueLength + CRLF2.length;
17011
+ checkLength(partLength);
17012
+ length += partLength;
17013
+ parts.push({ header, value, isString: isString2 });
17014
+ }
17015
+ const blobParts = [];
17016
+ for (const part of parts) {
17017
+ blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF2);
17018
+ }
17019
+ blobParts.push(footer);
17020
+ return new Blob2(blobParts, { type: "multipart/form-data; boundary=" + boundary });
17021
+ }
17022
+
17023
+ // ../node_modules/axios/lib/core/createMultipartBody.js
17024
+ function createMultipartBody(form, Blob2, limit, limitError, boundary) {
17025
+ if (!utils_default.isFunction(Blob2)) {
17026
+ throw new AxiosError_default("Blob is not supported", AxiosError_default.ERR_NOT_SUPPORT);
17027
+ }
17028
+ if (boundary === void 0) {
17029
+ if (utils_default.isFunction(platform_default.generateString)) {
17030
+ boundary = "axios-" + platform_default.generateString(36, "0123456789abcdef");
17031
+ } else {
17032
+ const crypto2 = utils_default.global.crypto;
17033
+ if (!crypto2 || !utils_default.isFunction(crypto2.getRandomValues)) {
17034
+ throw new AxiosError_default("Random byte generation is not supported", AxiosError_default.ERR_NOT_SUPPORT);
17035
+ }
17036
+ const random = new Uint8Array(18);
17037
+ crypto2.getRandomValues(random);
17038
+ boundary = "axios-" + Array.from(random, (value) => ("0" + value.toString(16)).slice(-2)).join("");
17039
+ }
17040
+ }
17041
+ try {
17042
+ return formDataToBlob(form, Blob2, limit, limitError, boundary);
17043
+ } catch (error) {
17044
+ if (error instanceof FormDataError) {
17045
+ const code = error.reason === "boundary" ? AxiosError_default.ERR_BAD_OPTION_VALUE : AxiosError_default.ERR_BAD_REQUEST;
17046
+ throw new AxiosError_default(error.message, code);
17047
+ }
17048
+ throw error;
17049
+ }
17050
+ }
17051
+
16550
17052
  // ../node_modules/axios/lib/adapters/fetch.js
16551
17053
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
16552
17054
  var DEFAULT_REQUEST_OPTIONS = {
@@ -16599,11 +17101,13 @@ var factory = (env) => {
16599
17101
  },
16600
17102
  {
16601
17103
  Request: globalObject.Request,
16602
- Response: globalObject.Response
17104
+ Response: globalObject.Response,
17105
+ Blob: globalObject.Blob
16603
17106
  },
16604
17107
  env
16605
17108
  );
16606
- const { fetch: envFetch, Request, Response } = env;
17109
+ const envFetch = utils_default.hasOwnProp(env, "fetch") ? env.fetch : void 0;
17110
+ const { Request, Response, Blob: Blob2 } = env;
16607
17111
  const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
16608
17112
  const isRequestSupported = isFunction2(Request);
16609
17113
  const isResponseSupported = isFunction2(Response);
@@ -16629,6 +17133,13 @@ var factory = (env) => {
16629
17133
  return duplexAccessed && !hasContentType;
16630
17134
  });
16631
17135
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
17136
+ const requestDefaults = Object.assign(/* @__PURE__ */ Object.create(null), DEFAULT_REQUEST_OPTIONS);
17137
+ if (isRequestSupported && !test(() => new Request(platform_default.origin, requestDefaults))) {
17138
+ delete requestDefaults.cache;
17139
+ if (!test(() => new Request(platform_default.origin, requestDefaults))) {
17140
+ requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
17141
+ }
17142
+ }
16632
17143
  const resolvers = {
16633
17144
  stream: supportsResponseStream && ((res) => res.body)
16634
17145
  };
@@ -16654,13 +17165,6 @@ var factory = (env) => {
16654
17165
  if (utils_default.isBlob(body)) {
16655
17166
  return body.size;
16656
17167
  }
16657
- if (utils_default.isSpecCompliantForm(body)) {
16658
- const _request = new Request(platform_default.origin, {
16659
- method: "POST",
16660
- body
16661
- });
16662
- return (await _request.arrayBuffer()).byteLength;
16663
- }
16664
17168
  if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
16665
17169
  return body.byteLength;
16666
17170
  }
@@ -16708,6 +17212,7 @@ var factory = (env) => {
16708
17212
  });
16709
17213
  let requestContentLength;
16710
17214
  let pendingBodyError = null;
17215
+ let pendingResponseError = null;
16711
17216
  const maxBodyLengthError = () => new AxiosError_default(
16712
17217
  "Request body larger than maxBodyLength limit",
16713
17218
  AxiosError_default.ERR_BAD_REQUEST,
@@ -16725,8 +17230,9 @@ var factory = (env) => {
16725
17230
  password
16726
17231
  };
16727
17232
  }
17233
+ let parsedURL;
16728
17234
  if (maybeWithAuthCredentials(url2)) {
16729
- const parsedURL = new URL(url2, platform_default.origin);
17235
+ parsedURL = new URL(url2, platform_default.origin);
16730
17236
  if (!auth && (parsedURL.username || parsedURL.password)) {
16731
17237
  const urlUsername = decodeURIComponentSafe2(parsedURL.username);
16732
17238
  const urlPassword = decodeURIComponentSafe2(parsedURL.password);
@@ -16748,8 +17254,8 @@ var factory = (env) => {
16748
17254
  "Basic " + btoa(encodeUTF82((auth.username || "") + ":" + (auth.password || "")))
16749
17255
  );
16750
17256
  }
16751
- if (hasMaxContentLength && typeof url2 === "string" && url2.startsWith("data:")) {
16752
- const estimated = estimateDataURLDecodedBytes(url2);
17257
+ if (hasMaxContentLength && parsedURL && parsedURL.protocol === "data:") {
17258
+ const estimated = estimateDataURLDecodedBytes(parsedURL.href);
16753
17259
  if (estimated > maxContentLength) {
16754
17260
  throw new AxiosError_default(
16755
17261
  "maxContentLength size of " + maxContentLength + " exceeded",
@@ -16759,6 +17265,23 @@ var factory = (env) => {
16759
17265
  );
16760
17266
  }
16761
17267
  }
17268
+ const formContentType = utils_default.isSpecCompliantForm(data) && AxiosHeaders_default.from(own2("headers")).getContentType();
17269
+ let formBoundary;
17270
+ if (utils_default.isString(formContentType) && /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())) {
17271
+ const parameters = AxiosHeaders_default.parseParameters(formContentType);
17272
+ if (utils_default.hasOwnProp(parameters, "boundary")) formBoundary = parameters.boundary;
17273
+ }
17274
+ if (utils_default.isSpecCompliantForm(data) && method !== "get" && method !== "head" && (hasMaxBodyLength || onUploadProgress && supportsRequestStream || formBoundary !== void 0)) {
17275
+ data = createMultipartBody(
17276
+ data,
17277
+ Blob2,
17278
+ hasMaxBodyLength ? maxBodyLength : Infinity,
17279
+ maxBodyLengthError,
17280
+ formBoundary
17281
+ );
17282
+ headers.setContentType(formBoundary === void 0 ? data.type : formContentType);
17283
+ requestContentLength = data.size;
17284
+ }
16762
17285
  if (hasMaxBodyLength && method !== "get" && method !== "head") {
16763
17286
  const outboundLength = await getBodyLength(data);
16764
17287
  if (typeof outboundLength === "number" && isFinite(outboundLength)) {
@@ -16839,7 +17362,7 @@ var factory = (env) => {
16839
17362
  credentials: isCredentialsSupported ? withCredentials : void 0
16840
17363
  });
16841
17364
  if (isRequestSupported) {
16842
- utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
17365
+ utils_default.forEach(requestDefaults, (value, key) => {
16843
17366
  if (resolvedOptions[key] === void 0) {
16844
17367
  resolvedOptions[key] = value;
16845
17368
  }
@@ -16887,7 +17410,7 @@ var factory = (env) => {
16887
17410
  if (hasMaxContentLength) {
16888
17411
  bytesRead = loadedBytes;
16889
17412
  if (bytesRead > maxContentLength) {
16890
- throw new AxiosError_default(
17413
+ throw pendingResponseError = new AxiosError_default(
16891
17414
  "maxContentLength size of " + maxContentLength + " exceeded",
16892
17415
  AxiosError_default.ERR_BAD_RESPONSE,
16893
17416
  config,
@@ -16962,6 +17485,9 @@ var factory = (env) => {
16962
17485
  request && !pendingBodyError.request && (pendingBodyError.request = request);
16963
17486
  throw pendingBodyError;
16964
17487
  }
17488
+ if (pendingResponseError) {
17489
+ throw pendingResponseError;
17490
+ }
16965
17491
  if (err instanceof AxiosError_default) {
16966
17492
  request && !err.request && (err.request = request);
16967
17493
  throw err;
@@ -16989,9 +17515,15 @@ var factory = (env) => {
16989
17515
  };
16990
17516
  var seedCache = /* @__PURE__ */ new Map();
16991
17517
  var getFetch = (config) => {
16992
- let env = config && config.env || {};
16993
- const { fetch: fetch2, Request, Response } = env;
16994
- const seeds = [Request, Response, fetch2];
17518
+ const env = /* @__PURE__ */ Object.create(null);
17519
+ const configuredEnv = config && utils_default.hasOwnProp(config, "env") && config.env;
17520
+ ["fetch", "Request", "Response", "Blob"].forEach((key) => {
17521
+ if (configuredEnv && utils_default.hasOwnProp(configuredEnv, key)) {
17522
+ env[key] = configuredEnv[key];
17523
+ }
17524
+ });
17525
+ const { fetch: fetch2, Request, Response, Blob: Blob2 } = env;
17526
+ const seeds = [Request, Response, fetch2, Blob2];
16995
17527
  let len = seeds.length, i = len, seed, target, map = seedCache;
16996
17528
  while (i--) {
16997
17529
  seed = seeds[i];
@@ -17077,6 +17609,9 @@ function throwIfCancellationRequested(config) {
17077
17609
  throw new CanceledError_default(null, config);
17078
17610
  }
17079
17611
  }
17612
+ function elapsedSince(start) {
17613
+ return Math.max(0, Date.now() - start);
17614
+ }
17080
17615
  function dispatchRequest(_config) {
17081
17616
  const config = utils_default.toSafeFlatObject(_config);
17082
17617
  throwIfCancellationRequested(config);
@@ -17086,9 +17621,11 @@ function dispatchRequest(_config) {
17086
17621
  config.headers.setContentType("application/x-www-form-urlencoded", false);
17087
17622
  }
17088
17623
  const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
17624
+ const start = Date.now();
17089
17625
  return adapter2(config).then(
17090
17626
  function onAdapterResolution(response) {
17091
17627
  throwIfCancellationRequested(config);
17628
+ response.duration = elapsedSince(start);
17092
17629
  config.response = response;
17093
17630
  try {
17094
17631
  response.data = transformData.call(config, config.transformResponse, response);
@@ -17102,6 +17639,7 @@ function dispatchRequest(_config) {
17102
17639
  if (!isCancel(reason)) {
17103
17640
  throwIfCancellationRequested(config);
17104
17641
  if (reason && reason.response) {
17642
+ reason.response.duration = elapsedSince(start);
17105
17643
  config.response = reason.response;
17106
17644
  try {
17107
17645
  reason.response.data = transformData.call(
@@ -17189,6 +17727,27 @@ var validator_default = {
17189
17727
 
17190
17728
  // ../node_modules/axios/lib/core/Axios.js
17191
17729
  var validators2 = validator_default.validators;
17730
+ var isHeadersBucket = (value) => {
17731
+ if (value == null || utils_default.isPlainObject(value) || value instanceof AxiosHeaders_default) {
17732
+ return true;
17733
+ }
17734
+ try {
17735
+ return utils_default.isObject(value) && utils_default.getSafeProp(value, Symbol.toStringTag) === "AxiosHeaders" && [
17736
+ "toJSON",
17737
+ "set",
17738
+ "get",
17739
+ "has",
17740
+ "delete",
17741
+ "clear",
17742
+ "normalize",
17743
+ "concat",
17744
+ "toString",
17745
+ Symbol.iterator
17746
+ ].every((method) => utils_default.isFunction(utils_default.getSafeProp(value, method)));
17747
+ } catch (e) {
17748
+ return false;
17749
+ }
17750
+ };
17192
17751
  var Axios = class {
17193
17752
  constructor(instanceConfig) {
17194
17753
  this.defaults = instanceConfig || {};
@@ -17224,9 +17783,13 @@ var Axios = class {
17224
17783
  } else if (stack) {
17225
17784
  const firstNewlineIndex = stack.indexOf("\n");
17226
17785
  const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf("\n", firstNewlineIndex + 1);
17227
- const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? "" : stack.slice(secondNewlineIndex + 1);
17228
- if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
17229
- err.stack += "\n" + stack;
17786
+ const duplicateCheckSuffix = secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
17787
+ const currentStack = String(err.stack);
17788
+ const causeIndex = getCauseStackIndex(err, currentStack);
17789
+ const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
17790
+ const causeSection = causeIndex === -1 ? "" : currentStack.slice(causeIndex);
17791
+ if (!stackHead.endsWith(duplicateCheckSuffix)) {
17792
+ err.stack = stackHead + "\n" + stack + causeSection;
17230
17793
  }
17231
17794
  }
17232
17795
  } catch (e) {
@@ -17253,7 +17816,8 @@ var Axios = class {
17253
17816
  clarifyTimeoutError: validators2.transitional(validators2.boolean),
17254
17817
  legacyInterceptorReqResOrdering: validators2.transitional(validators2.boolean),
17255
17818
  advertiseZstdAcceptEncoding: validators2.transitional(validators2.boolean),
17256
- validateStatusUndefinedResolves: validators2.transitional(validators2.boolean)
17819
+ validateStatusUndefinedResolves: validators2.transitional(validators2.boolean),
17820
+ encodeBasicAuthUsername: validators2.transitional(validators2.boolean)
17257
17821
  },
17258
17822
  false
17259
17823
  );
@@ -17274,7 +17838,7 @@ var Axios = class {
17274
17838
  );
17275
17839
  }
17276
17840
  }
17277
- if (config.allowAbsoluteUrls !== void 0) ; else if (this.defaults.allowAbsoluteUrls !== void 0) {
17841
+ if (config.allowAbsoluteUrls !== void 0) ; else if (utils_default.hasOwnProp(this.defaults, "allowAbsoluteUrls") && this.defaults.allowAbsoluteUrls !== void 0) {
17278
17842
  config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
17279
17843
  } else {
17280
17844
  config.allowAbsoluteUrls = true;
@@ -17288,9 +17852,16 @@ var Axios = class {
17288
17852
  true
17289
17853
  );
17290
17854
  config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
17291
- let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
17855
+ const commonHeaders = utils_default.getSafeProp(headers, "common");
17856
+ const methodHeaders = utils_default.getSafeProp(headers, config.method);
17857
+ const contextHeaders = headers && utils_default.merge(
17858
+ isHeadersBucket(commonHeaders) ? commonHeaders : void 0,
17859
+ isHeadersBucket(methodHeaders) ? methodHeaders : void 0
17860
+ );
17292
17861
  headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
17293
- delete headers[method];
17862
+ if (isHeadersBucket(utils_default.getSafeProp(headers, method))) {
17863
+ delete headers[method];
17864
+ }
17294
17865
  });
17295
17866
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
17296
17867
  const requestInterceptorChain = [];
@@ -17372,7 +17943,7 @@ var Axios = class {
17372
17943
  }
17373
17944
  };
17374
17945
  utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
17375
- Axios.prototype[method] = function(url2, config) {
17946
+ Axios.prototype[method] = async function(url2, config) {
17376
17947
  return this.request(
17377
17948
  mergeConfig(config || {}, {
17378
17949
  method,
@@ -17384,7 +17955,7 @@ utils_default.forEach(["delete", "get", "head", "options"], function forEachMeth
17384
17955
  });
17385
17956
  utils_default.forEach(["post", "put", "patch", "query"], function forEachMethodWithData(method) {
17386
17957
  function generateHTTPMethod(isForm) {
17387
- return function httpMethod(url2, data, config) {
17958
+ return async function httpMethod(url2, data, config) {
17388
17959
  return this.request(
17389
17960
  mergeConfig(config || {}, {
17390
17961
  method,
@@ -17894,12 +18465,94 @@ var ServerError = class extends Posty5Error {
17894
18465
  this.name = "ServerError";
17895
18466
  }
17896
18467
  };
18468
+ var ConflictError = class extends Posty5Error {
18469
+ constructor(message = "The document was changed by someone else", currentVersion = -1, resourceId = "", details) {
18470
+ super(message, "VERSION_CONFLICT", 409, details);
18471
+ this.name = "ConflictError";
18472
+ this.currentVersion = currentVersion;
18473
+ this.resourceId = resourceId;
18474
+ }
18475
+ };
18476
+ var VersionRequiredError = class extends Posty5Error {
18477
+ constructor(message = "The document version is required", details) {
18478
+ super(message, "VERSION_REQUIRED", 428, details);
18479
+ this.name = "VersionRequiredError";
18480
+ }
18481
+ };
18482
+ var CORE_VERSION = "5.0.2";
18483
+ var DEFAULT_BASE_URL = "https://api.posty5.com";
18484
+ var DEFAULT_TIMEOUT_MS = 3e4;
18485
+ var DEFAULT_MAX_RETRIES = 3;
18486
+ var DEFAULT_RETRY_DELAY_MS = 1e3;
18487
+ var CLIENT_HEADER_NAME = "X-Posty5-Client";
18488
+ var SDK_CLIENT_NAME = "posty5-npm";
18489
+ var SDK_CLIENT_ID = `${SDK_CLIENT_NAME}/${CORE_VERSION}`;
18490
+ var DEFAULT_CREATED_FROM = "npmPackage";
18491
+ var IDEMPOTENT_METHODS = ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"];
18492
+ var NEVER_CONNECTED_ERROR_CODES = ["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ENETUNREACH", "EHOSTUNREACH"];
18493
+ var API_KEY_HEADER_NAME = "X-API-Key";
18494
+ var REDACTED_VALUE = "[REDACTED]";
18495
+ var LOOPBACK_HOSTNAMES2 = ["localhost", "127.0.0.1", "[::1]", "::1"];
18496
+ var DOT_SEGMENT_PATTERN = /^(?:\.|%2e){1,2}$/i;
18497
+ function assertNoDotSegments(url2) {
18498
+ const path = url2.split(/[?#]/)[0];
18499
+ if (path.split("/").some((segment) => DOT_SEGMENT_PATTERN.test(segment))) {
18500
+ throw new Posty5Error(`Invalid request path "${url2}": "." and ".." segments are not allowed`, "INVALID_PATH");
18501
+ }
18502
+ }
18503
+ function redactHeaders(headers) {
18504
+ if (!headers || typeof headers !== "object") return;
18505
+ for (const name of Object.keys(headers)) {
18506
+ if (name.toLowerCase() === API_KEY_HEADER_NAME.toLowerCase()) headers[name] = REDACTED_VALUE;
18507
+ }
18508
+ }
18509
+ function hideProperty(target, key) {
18510
+ if (!target || !(key in target)) return;
18511
+ Object.defineProperty(target, key, { value: target[key], enumerable: false, configurable: true, writable: true });
18512
+ }
18513
+ function redactApiKey(error) {
18514
+ const axiosError = error;
18515
+ if (!axiosError || typeof axiosError !== "object") return error;
18516
+ redactHeaders(axiosError.config?.headers);
18517
+ redactHeaders(axiosError.response?.config?.headers);
18518
+ hideProperty(axiosError, "request");
18519
+ hideProperty(axiosError.response, "request");
18520
+ return error;
18521
+ }
18522
+ function originOf(protocol, hostname, port) {
18523
+ const resolvedPort = port ? String(port) : protocol === "https:" ? "443" : "80";
18524
+ return `${protocol}//${hostname.toLowerCase()}:${resolvedPort}`;
18525
+ }
18526
+ function apiKeyRedirectGuard(baseUrl) {
18527
+ let baseOrigin;
18528
+ try {
18529
+ const base = new URL(baseUrl);
18530
+ baseOrigin = originOf(base.protocol, base.hostname, base.port);
18531
+ } catch {
18532
+ baseOrigin = void 0;
18533
+ }
18534
+ return (options) => {
18535
+ const target = originOf(String(options.protocol || ""), String(options.hostname || options.host || ""), options.port);
18536
+ if (target === baseOrigin) return;
18537
+ for (const name of Object.keys(options.headers || {})) {
18538
+ if (name.toLowerCase() === API_KEY_HEADER_NAME.toLowerCase()) delete options.headers[name];
18539
+ }
18540
+ };
18541
+ }
18542
+ function isInsecureBaseUrl(baseUrl) {
18543
+ try {
18544
+ const url2 = new URL(baseUrl);
18545
+ return url2.protocol === "http:" && !LOOPBACK_HOSTNAMES2.includes(url2.hostname.toLowerCase());
18546
+ } catch {
18547
+ return false;
18548
+ }
18549
+ }
17897
18550
  function transformError(error) {
17898
18551
  if (error instanceof Posty5Error) {
17899
18552
  return error;
17900
18553
  }
17901
18554
  if (error.isAxiosError) {
17902
- const axiosError = error;
18555
+ const axiosError = redactApiKey(error);
17903
18556
  if (!axiosError.response) {
17904
18557
  if (axiosError.code === "ECONNABORTED" || axiosError.message.includes("timeout")) {
17905
18558
  return new NetworkError("Request timeout", { originalError: error });
@@ -17918,6 +18571,22 @@ function transformError(error) {
17918
18571
  return new AuthorizationError(message, details);
17919
18572
  case 404:
17920
18573
  return new NotFoundError(message, details);
18574
+ case 409: {
18575
+ const body = data;
18576
+ if (body?.code === "VERSION_CONFLICT") {
18577
+ const result = body?.result ?? {};
18578
+ const current = Number(result.currentVersion ?? body?.currentVersion);
18579
+ return new ConflictError(
18580
+ message,
18581
+ Number.isFinite(current) ? current : -1,
18582
+ String(result._id ?? body?._id ?? ""),
18583
+ details
18584
+ );
18585
+ }
18586
+ return new Posty5Error(message, body?.code, status, details);
18587
+ }
18588
+ case 428:
18589
+ return new VersionRequiredError(message, details);
17921
18590
  case 429:
17922
18591
  const retryAfter2 = axiosError.response.headers["retry-after"];
17923
18592
  return new RateLimitError(
@@ -17939,6 +18608,69 @@ function transformError(error) {
17939
18608
  }
17940
18609
  return new Posty5Error("An unknown error occurred", void 0, void 0, { originalError: error });
17941
18610
  }
18611
+ var IF_MATCH_HEADER = "If-Match";
18612
+ var CONCURRENCY_REPORT_HEADER = "X-Posty5-Concurrency";
18613
+ var CONCURRENCY_REPORT_MISSING_VERSION = "missing-version";
18614
+ var NON_RETRYABLE_VERSION_STATUSES = [409, 428];
18615
+ function assertVersion(version, name = "version") {
18616
+ if (typeof version !== "number" || !Number.isInteger(version) || version < 0) {
18617
+ throw new TypeError(`Posty5: \`${name}\` must be a non-negative integer (the document's __v), got ${String(version)}`);
18618
+ }
18619
+ }
18620
+ function ifMatchHeader(version) {
18621
+ assertVersion(version);
18622
+ return `"${version}"`;
18623
+ }
18624
+ function hasIfMatch(headers) {
18625
+ if (!headers) return false;
18626
+ if (typeof headers.get === "function") {
18627
+ const value = headers.get(IF_MATCH_HEADER);
18628
+ if (value !== void 0 && value !== null) return true;
18629
+ }
18630
+ return Object.keys(headers).some((key) => key.toLowerCase() === IF_MATCH_HEADER.toLowerCase());
18631
+ }
18632
+ function withVersion(response, id) {
18633
+ const result = response.result && typeof response.result === "object" ? { ...response.result } : {};
18634
+ if (id !== void 0 && result._id === void 0) result._id = id;
18635
+ if (typeof response.version === "number") result.__v = response.version;
18636
+ return result;
18637
+ }
18638
+ var missingVersionWarned = false;
18639
+ function warnOnMissingVersion(headers, method, url2) {
18640
+ if (missingVersionWarned || !headers) return false;
18641
+ const value = typeof headers.get === "function" ? headers.get(CONCURRENCY_REPORT_HEADER) : headers[CONCURRENCY_REPORT_HEADER.toLowerCase()];
18642
+ if (String(value ?? "").toLowerCase() !== CONCURRENCY_REPORT_MISSING_VERSION) return false;
18643
+ missingVersionWarned = true;
18644
+ console.warn(
18645
+ `[Posty5 SDK] ${String(method || "").toUpperCase()} ${url2 ?? ""} was sent without a document version; the API will refuse it once versions are enforced. Please report this SDK bug.`
18646
+ );
18647
+ return true;
18648
+ }
18649
+ function shouldRetryRequest(error) {
18650
+ const method = String(error?.config?.method || "").toUpperCase();
18651
+ const idempotent = IDEMPOTENT_METHODS.includes(method);
18652
+ const status = error?.response?.status;
18653
+ if (hasIfMatch(error?.config?.headers)) return false;
18654
+ if (status !== void 0 && NON_RETRYABLE_VERSION_STATUSES.includes(status)) return false;
18655
+ if (status === void 0) {
18656
+ if (idempotent) return esm_default.isNetworkError(error);
18657
+ return NEVER_CONNECTED_ERROR_CODES.includes(String(error?.code || ""));
18658
+ }
18659
+ return idempotent && status >= 500;
18660
+ }
18661
+ function decodeBinaryErrorBody(error) {
18662
+ const response = error?.response;
18663
+ const data = response?.data;
18664
+ const isBytes = data instanceof ArrayBuffer || typeof Uint8Array !== "undefined" && data instanceof Uint8Array;
18665
+ if (!isBytes) return error;
18666
+ const text = new TextDecoder().decode(data).trim();
18667
+ if (!text) return error;
18668
+ try {
18669
+ response.data = JSON.parse(text);
18670
+ } catch {
18671
+ }
18672
+ return error;
18673
+ }
17942
18674
  function parseFileName(disposition) {
17943
18675
  if (!disposition) return void 0;
17944
18676
  const match = /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(disposition);
@@ -17949,39 +18681,47 @@ function parseFileName(disposition) {
17949
18681
  return match[1];
17950
18682
  }
17951
18683
  }
18684
+ var apiKeys = /* @__PURE__ */ new WeakMap();
17952
18685
  var HttpClient = class {
17953
18686
  constructor(config = {}) {
18687
+ const { apiKey, ...publicConfig } = config;
18688
+ apiKeys.set(this, apiKey);
17954
18689
  this.config = {
17955
- timeout: 3e4,
17956
- maxRetries: 3,
17957
- retryDelay: 1e3,
17958
- ...config,
17959
- baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL || "https://api.posty5.com"
18690
+ timeout: DEFAULT_TIMEOUT_MS,
18691
+ maxRetries: DEFAULT_MAX_RETRIES,
18692
+ retryDelay: DEFAULT_RETRY_DELAY_MS,
18693
+ ...publicConfig,
18694
+ baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL || DEFAULT_BASE_URL
17960
18695
  };
18696
+ if (isInsecureBaseUrl(this.config.baseUrl)) {
18697
+ console.warn(`[Posty5 SDK] baseUrl ${this.config.baseUrl} is plain http: the API key travels unencrypted. Use https.`);
18698
+ }
17961
18699
  this.axiosInstance = axios_default.create({
17962
18700
  baseURL: this.config.baseUrl,
17963
18701
  timeout: this.config.timeout,
17964
18702
  headers: {
17965
18703
  "Content-Type": "application/json",
18704
+ [CLIENT_HEADER_NAME]: SDK_CLIENT_ID,
17966
18705
  ...this.config.headers
17967
- }
18706
+ },
18707
+ // A redirect to another origin must not carry the API key along.
18708
+ beforeRedirect: apiKeyRedirectGuard(this.config.baseUrl)
17968
18709
  });
17969
18710
  esm_default(this.axiosInstance, {
17970
- retries: this.config.maxRetries || 3,
18711
+ retries: this.config.maxRetries ?? DEFAULT_MAX_RETRIES,
17971
18712
  retryDelay: (retryCount) => {
17972
- return retryCount * (this.config.retryDelay || 1e3);
18713
+ return retryCount * (this.config.retryDelay ?? DEFAULT_RETRY_DELAY_MS);
17973
18714
  },
17974
- retryCondition: (error) => {
17975
- return esm_default.isNetworkOrIdempotentRequestError(error) || error.response?.status !== void 0 && error.response.status >= 500;
17976
- }
18715
+ retryCondition: shouldRetryRequest
17977
18716
  });
17978
18717
  this.axiosInstance.interceptors.request.use(
17979
18718
  (config2) => {
17980
- if (this.config.apiKey) {
17981
- config2.headers["X-API-Key"] = this.config.apiKey;
18719
+ const apiKey2 = apiKeys.get(this);
18720
+ if (apiKey2) {
18721
+ config2.headers[API_KEY_HEADER_NAME] = apiKey2;
17982
18722
  } else {
17983
18723
  if (process.env.POSTY5_API_KEY) {
17984
- config2.headers["X-API-Key"] = process.env.POSTY5_API_KEY;
18724
+ config2.headers[API_KEY_HEADER_NAME] = process.env.POSTY5_API_KEY;
17985
18725
  }
17986
18726
  }
17987
18727
  if (this.config.debug) {
@@ -17995,13 +18735,14 @@ var HttpClient = class {
17995
18735
  },
17996
18736
  (error) => {
17997
18737
  if (this.config.debug) {
17998
- console.log("[Posty5 SDK] Request Error:", error);
18738
+ console.log("[Posty5 SDK] Request Error:", error?.message);
17999
18739
  }
18000
18740
  return Promise.reject(transformError(error));
18001
18741
  }
18002
18742
  );
18003
18743
  this.axiosInstance.interceptors.response.use(
18004
18744
  (response) => {
18745
+ warnOnMissingVersion(response.headers, response.config?.method, response.config?.url);
18005
18746
  if (this.config.debug) {
18006
18747
  console.log("[Posty5 SDK] Response:", {
18007
18748
  status: response.status,
@@ -18014,27 +18755,32 @@ var HttpClient = class {
18014
18755
  if (this.config.debug) {
18015
18756
  console.error("[Posty5 SDK] Error:", JSON.stringify(error.response?.data || error.message));
18016
18757
  }
18017
- return Promise.reject(transformError(error));
18758
+ return Promise.reject(transformError(decodeBinaryErrorBody(error)));
18018
18759
  }
18019
18760
  );
18020
18761
  }
18762
+ /** The `createdFrom` label the clients stamp on records they create. */
18763
+ get createdFrom() {
18764
+ return this.config.createdFrom || DEFAULT_CREATED_FROM;
18765
+ }
18021
18766
  /**
18022
18767
  * Set or update the API key
18023
18768
  */
18024
18769
  setApiKey(apiKey) {
18025
- this.config.apiKey = apiKey;
18770
+ apiKeys.set(this, apiKey);
18026
18771
  }
18027
18772
  /**
18028
18773
  * Clear authentication credentials
18029
18774
  */
18030
18775
  clearAuth() {
18031
- this.config.apiKey = void 0;
18776
+ apiKeys.set(this, void 0);
18032
18777
  }
18033
18778
  /**
18034
18779
  * Make a GET request
18035
18780
  */
18036
18781
  async get(url2, config) {
18037
18782
  try {
18783
+ assertNoDotSegments(url2);
18038
18784
  const response = await this.axiosInstance.get(url2, this.buildConfig(config));
18039
18785
  return response.data;
18040
18786
  } catch (error) {
@@ -18046,6 +18792,7 @@ var HttpClient = class {
18046
18792
  */
18047
18793
  async post(url2, data, config) {
18048
18794
  try {
18795
+ assertNoDotSegments(url2);
18049
18796
  const response = await this.axiosInstance.post(url2, data, this.buildConfig(config));
18050
18797
  return response.data;
18051
18798
  } catch (error) {
@@ -18057,6 +18804,7 @@ var HttpClient = class {
18057
18804
  */
18058
18805
  async put(url2, data, config) {
18059
18806
  try {
18807
+ assertNoDotSegments(url2);
18060
18808
  const response = await this.axiosInstance.put(url2, data, this.buildConfig(config));
18061
18809
  return response.data;
18062
18810
  } catch (error) {
@@ -18068,11 +18816,12 @@ var HttpClient = class {
18068
18816
  */
18069
18817
  async patch(url2, data, config) {
18070
18818
  try {
18819
+ assertNoDotSegments(url2);
18071
18820
  const response = await this.axiosInstance.patch(url2, data, this.buildConfig(config));
18072
18821
  return response.data;
18073
18822
  } catch (error) {
18074
18823
  if (this.config.debug) {
18075
- console.log("[Posty5 SDK] PATCH Request Error:", error);
18824
+ console.log("[Posty5 SDK] PATCH Request Error:", error?.message);
18076
18825
  }
18077
18826
  throw transformError(error);
18078
18827
  }
@@ -18082,11 +18831,12 @@ var HttpClient = class {
18082
18831
  */
18083
18832
  async delete(url2, config) {
18084
18833
  try {
18834
+ assertNoDotSegments(url2);
18085
18835
  const response = await this.axiosInstance.delete(url2, this.buildConfig(config));
18086
18836
  return response.data;
18087
18837
  } catch (error) {
18088
18838
  if (this.config.debug) {
18089
- console.log("[Posty5 SDK] DELETE Request Error:", error);
18839
+ console.log("[Posty5 SDK] DELETE Request Error:", error?.message);
18090
18840
  }
18091
18841
  throw transformError(error);
18092
18842
  }
@@ -18100,6 +18850,7 @@ var HttpClient = class {
18100
18850
  */
18101
18851
  async getBinary(url2, config) {
18102
18852
  try {
18853
+ assertNoDotSegments(url2);
18103
18854
  const response = await this.axiosInstance.get(url2, {
18104
18855
  ...this.buildConfig(config),
18105
18856
  responseType: "arraybuffer"
@@ -18122,11 +18873,18 @@ var HttpClient = class {
18122
18873
  }
18123
18874
  const axiosConfig = {};
18124
18875
  if (config.headers) {
18125
- axiosConfig.headers = config.headers;
18876
+ axiosConfig.headers = { ...config.headers };
18877
+ }
18878
+ if (config.version !== void 0) {
18879
+ axiosConfig.headers = { ...axiosConfig.headers || {}, [IF_MATCH_HEADER]: ifMatchHeader(config.version) };
18880
+ axiosConfig["axios-retry"] = { retries: 0 };
18126
18881
  }
18127
18882
  if (config.params) {
18128
18883
  axiosConfig.params = config.params;
18129
18884
  }
18885
+ if (config.data !== void 0) {
18886
+ axiosConfig.data = config.data;
18887
+ }
18130
18888
  if (config.timeout) {
18131
18889
  axiosConfig.timeout = config.timeout;
18132
18890
  }
@@ -18384,7 +19142,7 @@ var SocialPublisherPostClient = class {
18384
19142
  * @param id - Post ID
18385
19143
  */
18386
19144
  async getStatus(id) {
18387
- const response = await this.http.get(`${this.basePath}/${id}/status`);
19145
+ const response = await this.http.get(`${this.basePath}/${encodeURIComponent(id)}/status`);
18388
19146
  return response.result;
18389
19147
  }
18390
19148
  /**
@@ -18406,24 +19164,27 @@ var SocialPublisherPostClient = class {
18406
19164
  * cannot be removed programmatically and no credits are charged.
18407
19165
  *
18408
19166
  * @param id - Post ID
18409
- * @returns Per-platform removal results
19167
+ * @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
19168
+ * @returns Per-platform removal results, `__v` set to the post's new version
18410
19169
  *
18411
19170
  * @example
18412
19171
  * ```ts
18413
- * const { results } = await client.removePost("post_123");
19172
+ * const post = await client.getStatus("post_123");
19173
+ * const { results } = await client.removePost("post_123", post.__v);
18414
19174
  * // results.youtube?.success === true
18415
19175
  * ```
18416
19176
  */
18417
- async removePost(id) {
18418
- const response = await this.http.post(`${this.basePath}/${id}/remove`, {});
18419
- return response.result;
19177
+ async removePost(id, version) {
19178
+ assertVersion(version);
19179
+ const response = await this.http.post(`${this.basePath}/${encodeURIComponent(id)}/remove`, {}, { version });
19180
+ return withVersion(response, id);
18420
19181
  }
18421
19182
  /**
18422
19183
  * Get next and previous post IDs
18423
19184
  * @param id - Current Post ID
18424
19185
  */
18425
19186
  async getNextAndPrevious(id) {
18426
- const response = await this.http.get(`${this.basePath}/${id}/next-previous`);
19187
+ const response = await this.http.get(`${this.basePath}/${encodeURIComponent(id)}/next-previous`);
18427
19188
  return response.result;
18428
19189
  }
18429
19190
  /**
@@ -18432,10 +19193,10 @@ var SocialPublisherPostClient = class {
18432
19193
  * @param id - Optional ID for updating/retrying? (Based on route :id?)
18433
19194
  */
18434
19195
  async createToWorkspaceByFile(data, id) {
18435
- const url2 = id ? `${this.basePath}/short-video/workspace/by-file/${id}` : `${this.basePath}/short-video/workspace/by-file`;
19196
+ const url2 = id ? `${this.basePath}/short-video/workspace/by-file/${encodeURIComponent(id)}` : `${this.basePath}/short-video/workspace/by-file`;
18436
19197
  const response = await this.http.post(url2, {
18437
19198
  ...data,
18438
- createdFrom: "npmPackage"
19199
+ createdFrom: this.http.createdFrom
18439
19200
  });
18440
19201
  return response.result?._id;
18441
19202
  }
@@ -18445,10 +19206,10 @@ var SocialPublisherPostClient = class {
18445
19206
  * @param id - Optional ID for updating/retrying? (Based on route :id?)
18446
19207
  */
18447
19208
  async createToWorkspaceByURL(data, id) {
18448
- const url2 = id ? `${this.basePath}/short-video/workspace/by-url/${id}` : `${this.basePath}/short-video/workspace/by-url`;
19209
+ const url2 = id ? `${this.basePath}/short-video/workspace/by-url/${encodeURIComponent(id)}` : `${this.basePath}/short-video/workspace/by-url`;
18449
19210
  const response = await this.http.post(url2, {
18450
19211
  ...data,
18451
- createdFrom: "npmPackage"
19212
+ createdFrom: this.http.createdFrom
18452
19213
  });
18453
19214
  return response.result?._id;
18454
19215
  }
@@ -18458,10 +19219,10 @@ var SocialPublisherPostClient = class {
18458
19219
  * @param id - Optional ID for updating/retrying?
18459
19220
  */
18460
19221
  async createToAccountByFile(data, id) {
18461
- const url2 = id ? `${this.basePath}/short-video/account/by-file/${id}` : `${this.basePath}/short-video/account/by-file`;
19222
+ const url2 = id ? `${this.basePath}/short-video/account/by-file/${encodeURIComponent(id)}` : `${this.basePath}/short-video/account/by-file`;
18462
19223
  const response = await this.http.post(url2, {
18463
19224
  ...data,
18464
- createdFrom: "npmPackage"
19225
+ createdFrom: this.http.createdFrom
18465
19226
  });
18466
19227
  return response.result?._id;
18467
19228
  }
@@ -18471,10 +19232,10 @@ var SocialPublisherPostClient = class {
18471
19232
  * @param id - Optional ID for updating/retrying?
18472
19233
  */
18473
19234
  async createToAccountByURL(data, id) {
18474
- const url2 = id ? `${this.basePath}/short-video/account/by-url/${id}` : `${this.basePath}/short-video/account/by-url`;
19235
+ const url2 = id ? `${this.basePath}/short-video/account/by-url/${encodeURIComponent(id)}` : `${this.basePath}/short-video/account/by-url`;
18475
19236
  const response = await this.http.post(url2, {
18476
19237
  ...data,
18477
- createdFrom: "npmPackage"
19238
+ createdFrom: this.http.createdFrom
18478
19239
  });
18479
19240
  return response.result?._id;
18480
19241
  }
@@ -18495,10 +19256,10 @@ var SocialPublisherPostClient = class {
18495
19256
  * ```
18496
19257
  */
18497
19258
  async createImagePostToWorkspace(data, id) {
18498
- const url2 = id ? `${this.basePath}/image/workspace/${id}` : `${this.basePath}/image/workspace`;
19259
+ const url2 = id ? `${this.basePath}/image/workspace/${encodeURIComponent(id)}` : `${this.basePath}/image/workspace`;
18499
19260
  const response = await this.http.post(url2, {
18500
19261
  ...data,
18501
- createdFrom: "npmPackage"
19262
+ createdFrom: this.http.createdFrom
18502
19263
  });
18503
19264
  return response.result?._id;
18504
19265
  }
@@ -18508,13 +19269,53 @@ var SocialPublisherPostClient = class {
18508
19269
  * platforms in the request are ignored.
18509
19270
  */
18510
19271
  async createImagePostToAccount(data, id) {
18511
- const url2 = id ? `${this.basePath}/image/account/${id}` : `${this.basePath}/image/account`;
19272
+ const url2 = id ? `${this.basePath}/image/account/${encodeURIComponent(id)}` : `${this.basePath}/image/account`;
18512
19273
  const response = await this.http.post(url2, {
18513
19274
  ...data,
18514
- createdFrom: "npmPackage"
19275
+ createdFrom: this.http.createdFrom
18515
19276
  });
18516
19277
  return response.result?._id;
18517
19278
  }
19279
+ /**
19280
+ * Publish a text-only post to every text-capable account in a workspace
19281
+ * (Facebook, Threads, X). Platforms that cannot take text are reported in
19282
+ * `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
19283
+ */
19284
+ async createTextPostToWorkspace(data) {
19285
+ const response = await this.http.post(`${this.basePath}/text/workspace`, {
19286
+ ...data,
19287
+ createdFrom: this.http.createdFrom
19288
+ });
19289
+ return response.result;
19290
+ }
19291
+ /** Publish a text-only post to one account. */
19292
+ async createTextPostToAccount(data) {
19293
+ const response = await this.http.post(`${this.basePath}/text/account`, {
19294
+ ...data,
19295
+ createdFrom: this.http.createdFrom
19296
+ });
19297
+ return response.result;
19298
+ }
19299
+ /**
19300
+ * Publish a story to every story-capable account in a workspace. Media by URL
19301
+ * only in this release: `image: { source: "image-url", externalUrl }`, or
19302
+ * `source: "video-url"` with `videoURL`.
19303
+ */
19304
+ async createStoryPostToWorkspace(data) {
19305
+ const response = await this.http.post(`${this.basePath}/story/workspace`, {
19306
+ ...data,
19307
+ createdFrom: this.http.createdFrom
19308
+ });
19309
+ return response.result;
19310
+ }
19311
+ /** Publish a story to one account. Media by URL only, as for the workspace form. */
19312
+ async createStoryPostToAccount(data) {
19313
+ const response = await this.http.post(`${this.basePath}/story/account`, {
19314
+ ...data,
19315
+ createdFrom: this.http.createdFrom
19316
+ });
19317
+ return response.result;
19318
+ }
18518
19319
  /**
18519
19320
  * Handle thumbnail upload - accepts either File or URL string
18520
19321
  * @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
@@ -18861,8 +19662,8 @@ var SocialPublisherPostClient = class {
18861
19662
  };
18862
19663
  const target = isFile2 ? "by-file" : "by-url";
18863
19664
  const id = postId ?? thumb?.postId;
18864
- const url2 = id ? `${this.basePath}/long-video/workspace/${target}/${id}` : `${this.basePath}/long-video/workspace/${target}`;
18865
- const response = await this.http.post(url2, { ...body, createdFrom: "npmPackage" });
19665
+ const url2 = id ? `${this.basePath}/long-video/workspace/${target}/${encodeURIComponent(id)}` : `${this.basePath}/long-video/workspace/${target}`;
19666
+ const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
18866
19667
  return this.normaliseLongVideoResult(response.result);
18867
19668
  }
18868
19669
  /**
@@ -18913,8 +19714,8 @@ var SocialPublisherPostClient = class {
18913
19714
  };
18914
19715
  const target = isFile2 ? "by-file" : "by-url";
18915
19716
  const id = postId ?? thumb?.postId;
18916
- const url2 = id ? `${this.basePath}/long-video/account/${target}/${id}` : `${this.basePath}/long-video/account/${target}`;
18917
- const response = await this.http.post(url2, { ...body, createdFrom: "npmPackage" });
19717
+ const url2 = id ? `${this.basePath}/long-video/account/${target}/${encodeURIComponent(id)}` : `${this.basePath}/long-video/account/${target}`;
19718
+ const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
18918
19719
  return this.normaliseLongVideoResult(response.result);
18919
19720
  }
18920
19721
  /**
@@ -18926,18 +19727,29 @@ var SocialPublisherPostClient = class {
18926
19727
  *
18927
19728
  * @example
18928
19729
  * ```ts
18929
- * await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") });
18930
- * await client.reschedulePost("post_123", { schedule: "now" });
19730
+ * const post = await client.getStatus("post_123");
19731
+ * const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
19732
+ * await client.reschedulePost("post_123", { schedule: "now" }, __v);
18931
19733
  * ```
19734
+ *
19735
+ * @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
19736
+ * @returns `{ _id, __v }`, `__v` being the new version
18932
19737
  */
18933
- async reschedulePost(id, data) {
19738
+ async reschedulePost(id, data, version) {
18934
19739
  if (!id) {
18935
19740
  throw new Error("id is required");
18936
19741
  }
18937
- await this.http.put(`${this.basePath}/${id}`, {
18938
- schedule: this.buildSchedule(data.schedule),
18939
- ...data.caption !== void 0 ? { caption: data.caption } : {}
18940
- });
19742
+ assertVersion(version);
19743
+ const response = await this.http.put(
19744
+ `${this.basePath}/${encodeURIComponent(id)}`,
19745
+ {
19746
+ ...data.schedule === "now" ? { scheduleType: "now" } : { scheduleType: "schedule", scheduledAt: data.schedule.toISOString() },
19747
+ ...data.caption !== void 0 ? { caption: data.caption } : {}
19748
+ },
19749
+ { version }
19750
+ );
19751
+ const updated = withVersion(response, id);
19752
+ return { _id: updated._id, __v: updated.__v };
18941
19753
  }
18942
19754
  /**
18943
19755
  * Delete a post that has not published yet, releasing its uploaded media in
@@ -18949,14 +19761,17 @@ var SocialPublisherPostClient = class {
18949
19761
  *
18950
19762
  * @example
18951
19763
  * ```ts
18952
- * await client.deletePost("post_123");
19764
+ * await client.deletePost("post_123", post.__v);
18953
19765
  * ```
19766
+ *
19767
+ * @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
18954
19768
  */
18955
- async deletePost(id) {
19769
+ async deletePost(id, version) {
18956
19770
  if (!id) {
18957
19771
  throw new Error("id is required");
18958
19772
  }
18959
- await this.http.delete(`${this.basePath}/${id}`);
19773
+ assertVersion(version);
19774
+ await this.http.delete(`${this.basePath}/${encodeURIComponent(id)}`, { version });
18960
19775
  }
18961
19776
  /**
18962
19777
  * Upload a long video and return the URL to publish from.