UNPKG

frappe-react-sdk

Version:
1,354 lines 207 kB
var eo = Object.defineProperty; var to = (t, e, n) => e in t ? eo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var it = (t, e, n) => to(t, typeof e != "symbol" ? e + "" : e, n); import { jsx as Xs } from "react/jsx-runtime"; import qt, { createContext as Or, useContext as ae, useMemo as Ut, useRef as Ue, createElement as no, useEffect as Et, useLayoutEffect as so, useCallback as V, useDebugValue as ro, useState as z } from "react"; var Un = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, mt = {}, Pt = {}, Pe = {}, Ys; function Tr() { if (Ys) return Pe; Ys = 1; var t = Pe && Pe.__assign || function() { return t = Object.assign || function(a) { for (var l, o = 1, d = arguments.length; o < d; o++) { l = arguments[o]; for (var h in l) Object.prototype.hasOwnProperty.call(l, h) && (a[h] = l[h]); } return a; }, t.apply(this, arguments); }, e = Pe && Pe.__awaiter || function(a, l, o, d) { function h(f) { return f instanceof o ? f : new o(function(y) { y(f); }); } return new (o || (o = Promise))(function(f, y) { function _(E) { try { m(d.next(E)); } catch (x) { y(x); } } function S(E) { try { m(d.throw(E)); } catch (x) { y(x); } } function m(E) { E.done ? f(E.value) : h(E.value).then(_, S); } m((d = d.apply(a, l || [])).next()); }); }, n = Pe && Pe.__generator || function(a, l) { var o = { label: 0, sent: function() { if (f[0] & 1) throw f[1]; return f[1]; }, trys: [], ops: [] }, d, h, f, y; return y = { next: _(0), throw: _(1), return: _(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() { return this; }), y; function _(m) { return function(E) { return S([m, E]); }; } function S(m) { if (d) throw new TypeError("Generator is already executing."); for (; y && (y = 0, m[0] && (o = 0)), o; ) try { if (d = 1, h && (f = m[0] & 2 ? h.return : m[0] ? h.throw || ((f = h.return) && f.call(h), 0) : h.next) && !(f = f.call(h, m[1])).done) return f; switch (h = 0, f && (m = [m[0] & 2, f.value]), m[0]) { case 0: case 1: f = m; break; case 4: return o.label++, { value: m[1], done: !1 }; case 5: o.label++, h = m[1], m = [0]; continue; case 7: m = o.ops.pop(), o.trys.pop(); continue; default: if (f = o.trys, !(f = f.length > 0 && f[f.length - 1]) && (m[0] === 6 || m[0] === 2)) { o = 0; continue; } if (m[0] === 3 && (!f || m[1] > f[0] && m[1] < f[3])) { o.label = m[1]; break; } if (m[0] === 6 && o.label < f[1]) { o.label = f[1], f = m; break; } if (f && o.label < f[2]) { o.label = f[2], o.ops.push(m); break; } f[2] && o.ops.pop(), o.trys.pop(); continue; } m = l.call(a, o); } catch (E) { m = [6, E], h = 0; } finally { d = f = 0; } if (m[0] & 5) throw m[1]; return { value: m[0] ? m[1] : void 0, done: !0 }; } }; Object.defineProperty(Pe, "__esModule", { value: !0 }), Pe.FrappeCall = void 0; var r = ( /** @class */ function() { function a(l, o, d, h, f) { this.appURL = l, this.axios = o, this.useToken = d ?? !1, this.token = h, this.tokenType = f; } return a.prototype.get = function(l, o) { return e(this, void 0, void 0, function() { var d; return n(this, function(h) { return d = new URLSearchParams(), o && Object.entries(o).forEach(function(f) { var y = f[0], _ = f[1]; if (_ != null) { var S = typeof _ == "object" ? JSON.stringify(_) : _; d.set(y, S); } }), [2, this.axios.get("/api/method/".concat(l), { params: d }).then(function(f) { return f.data; }).catch(function(f) { var y, _; throw t(t({}, f.response.data), { httpStatus: f.response.status, httpStatusText: f.response.statusText, message: (y = f.response.data.message) !== null && y !== void 0 ? y : "There was an error.", exception: (_ = f.response.data.exception) !== null && _ !== void 0 ? _ : "" }); })]; }); }); }, a.prototype.post = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/method/".concat(l), t({}, o)).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a.prototype.put = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.put("/api/method/".concat(l), t({}, o)).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a.prototype.delete = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/method/".concat(l), { params: o }).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a; }() ); return Pe.FrappeCall = r, Pe; } var ke = {}, Qs; function xr() { if (Qs) return ke; Qs = 1; var t = ke && ke.__assign || function() { return t = Object.assign || function(a) { for (var l, o = 1, d = arguments.length; o < d; o++) { l = arguments[o]; for (var h in l) Object.prototype.hasOwnProperty.call(l, h) && (a[h] = l[h]); } return a; }, t.apply(this, arguments); }, e = ke && ke.__awaiter || function(a, l, o, d) { function h(f) { return f instanceof o ? f : new o(function(y) { y(f); }); } return new (o || (o = Promise))(function(f, y) { function _(E) { try { m(d.next(E)); } catch (x) { y(x); } } function S(E) { try { m(d.throw(E)); } catch (x) { y(x); } } function m(E) { E.done ? f(E.value) : h(E.value).then(_, S); } m((d = d.apply(a, l || [])).next()); }); }, n = ke && ke.__generator || function(a, l) { var o = { label: 0, sent: function() { if (f[0] & 1) throw f[1]; return f[1]; }, trys: [], ops: [] }, d, h, f, y; return y = { next: _(0), throw: _(1), return: _(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() { return this; }), y; function _(m) { return function(E) { return S([m, E]); }; } function S(m) { if (d) throw new TypeError("Generator is already executing."); for (; y && (y = 0, m[0] && (o = 0)), o; ) try { if (d = 1, h && (f = m[0] & 2 ? h.return : m[0] ? h.throw || ((f = h.return) && f.call(h), 0) : h.next) && !(f = f.call(h, m[1])).done) return f; switch (h = 0, f && (m = [m[0] & 2, f.value]), m[0]) { case 0: case 1: f = m; break; case 4: return o.label++, { value: m[1], done: !1 }; case 5: o.label++, h = m[1], m = [0]; continue; case 7: m = o.ops.pop(), o.trys.pop(); continue; default: if (f = o.trys, !(f = f.length > 0 && f[f.length - 1]) && (m[0] === 6 || m[0] === 2)) { o = 0; continue; } if (m[0] === 3 && (!f || m[1] > f[0] && m[1] < f[3])) { o.label = m[1]; break; } if (m[0] === 6 && o.label < f[1]) { o.label = f[1], f = m; break; } if (f && o.label < f[2]) { o.label = f[2], o.ops.push(m); break; } f[2] && o.ops.pop(), o.trys.pop(); continue; } m = l.call(a, o); } catch (E) { m = [6, E], h = 0; } finally { d = f = 0; } if (m[0] & 5) throw m[1]; return { value: m[0] ? m[1] : void 0, done: !0 }; } }; Object.defineProperty(ke, "__esModule", { value: !0 }), ke.FrappeDB = void 0; var r = ( /** @class */ function() { function a(l, o, d, h, f) { this.appURL = l, this.axios = o, this.useToken = d ?? !1, this.token = h, this.tokenType = f; } return a.prototype.getDoc = function(l, o) { return o === void 0 && (o = ""), e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.get("/api/resource/".concat(l, "/").concat(encodeURIComponent(o))).then(function(h) { return h.data.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while fetching the document.", exception: (y = (f = h.response.data.exception) !== null && f !== void 0 ? f : h.response.data.exc_type) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a.prototype.getDocList = function(l, o) { var d; return e(this, void 0, void 0, function() { var h, f, y, _, S, m, E, x, F, J, D; return n(this, function(Z) { return h = {}, o && (f = o.fields, y = o.filters, _ = o.orFilters, S = o.orderBy, m = o.limit, E = o.limit_start, x = o.groupBy, F = o.asDict, J = F === void 0 ? !0 : F, D = S ? "".concat(String(S == null ? void 0 : S.field), " ").concat((d = S == null ? void 0 : S.order) !== null && d !== void 0 ? d : "asc") : "", h = { fields: f ? JSON.stringify(f) : void 0, filters: y ? JSON.stringify(y) : void 0, or_filters: _ ? JSON.stringify(_) : void 0, order_by: D, group_by: x, limit: m, limit_start: E, as_dict: J }), [2, this.axios.get("/api/resource/".concat(l), { params: h }).then(function(Y) { return Y.data.data; }).catch(function(Y) { var I, ie; throw t(t({}, Y.response.data), { httpStatus: Y.response.status, httpStatusText: Y.response.statusText, message: "There was an error while fetching the documents.", exception: (ie = (I = Y.response.data.exception) !== null && I !== void 0 ? I : Y.response.data.exc_type) !== null && ie !== void 0 ? ie : "" }); })]; }); }); }, a.prototype.createDoc = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/resource/".concat(l), t({}, o)).then(function(h) { return h.data.data; }).catch(function(h) { var f, y, _; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error while creating the document.", exception: (_ = (y = h.response.data.exception) !== null && y !== void 0 ? y : h.response.data.exc_type) !== null && _ !== void 0 ? _ : "" }); })]; }); }); }, a.prototype.updateDoc = function(l, o, d) { return e(this, void 0, void 0, function() { return n(this, function(h) { return [2, this.axios.put("/api/resource/".concat(l, "/").concat(o && encodeURIComponent(o)), t({}, d)).then(function(f) { return f.data.data; }).catch(function(f) { var y, _, S; throw t(t({}, f.response.data), { httpStatus: f.response.status, httpStatusText: f.response.statusText, message: (y = f.response.data.message) !== null && y !== void 0 ? y : "There was an error while updating the document.", exception: (S = (_ = f.response.data.exception) !== null && _ !== void 0 ? _ : f.response.data.exc_type) !== null && S !== void 0 ? S : "" }); })]; }); }); }, a.prototype.deleteDoc = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/resource/".concat(l, "/").concat(o && encodeURIComponent(o))).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while deleting the document.", exception: (y = (f = h.response.data.exception) !== null && f !== void 0 ? f : h.response.data.exc_type) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a.prototype.getCount = function(l, o, d) { return d === void 0 && (d = !1), e(this, void 0, void 0, function() { var h; return n(this, function(f) { return h = { doctype: l, filters: [] }, d && (h.debug = d), o && (h.filters = o ? JSON.stringify(o) : void 0), [2, this.axios.get("/api/method/frappe.client.get_count", { params: h }).then(function(y) { return y.data.message; }).catch(function(y) { var _, S; throw t(t({}, y.response.data), { httpStatus: y.response.status, httpStatusText: y.response.statusText, message: "There was an error while getting the count.", exception: (S = (_ = y.response.data.exception) !== null && _ !== void 0 ? _ : y.response.data.exc_type) !== null && S !== void 0 ? S : "" }); })]; }); }); }, a.prototype.getLastDoc = function(l, o) { return e(this, void 0, void 0, function() { var d, h; return n(this, function(f) { switch (f.label) { case 0: return d = { orderBy: { field: "creation", order: "desc" } }, o && (d = t(t({}, d), o)), [4, this.getDocList(l, t(t({}, d), { limit: 1, fields: ["name"] }))]; case 1: return h = f.sent(), h.length > 0 ? [2, this.getDoc(l, h[0].name)] : [2, {}]; } }); }); }, a.prototype.renameDoc = function(l, o, d, h) { return h === void 0 && (h = !1), e(this, void 0, void 0, function() { return n(this, function(f) { return [2, this.axios.post("/api/method/frappe.client.rename_doc", { doctype: l, old_name: o, new_name: d, merge: h }).then(function(y) { return y.data; }).catch(function(y) { var _, S, m; throw t(t({}, y.response.data), { httpStatus: y.response.status, httpStatusText: y.response.statusText, message: (_ = y.response.data.message) !== null && _ !== void 0 ? _ : "There was an error while renaming the document.", exception: (m = (S = y.response.data.exception) !== null && S !== void 0 ? S : y.response.data.exc_type) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a.prototype.getValue = function(l, o, d, h, f, y) { return h === void 0 && (h = !0), f === void 0 && (f = !1), y === void 0 && (y = null), e(this, void 0, void 0, function() { var _; return n(this, function(S) { return _ = { doctype: l, fieldname: "[]", filters: [], as_dict: h, debug: f, parent: null }, o && (_.fieldname = typeof o == "object" ? JSON.stringify(o) : o), d && (_.filters = d ? JSON.stringify(d) : void 0), y && (_.parent = y), [2, this.axios.get("/api/method/frappe.client.get_value", { params: _ }).then(function(m) { return m.data; }).catch(function(m) { var E, x; throw t(t({}, m.response.data), { httpStatus: m.response.status, httpStatusText: m.response.statusText, message: "There was an error while getting the value.", exception: (x = (E = m.response.data.exception) !== null && E !== void 0 ? E : m.response.data.exc_type) !== null && x !== void 0 ? x : "" }); })]; }); }); }, a.prototype.setValue = function(l, o, d, h) { return e(this, void 0, void 0, function() { return n(this, function(f) { return d !== null && typeof d == "object" && !Array.isArray(d) && (h = void 0), [2, this.axios.post("/api/method/frappe.client.set_value", { doctype: l, name: o, fieldname: d, value: h }).then(function(y) { return y.data; }).catch(function(y) { var _, S; throw t(t({}, y.response.data), { httpStatus: y.response.status, httpStatusText: y.response.statusText, message: "There was an error while setting the value.", exception: (S = (_ = y.response.data.exception) !== null && _ !== void 0 ? _ : y.response.data.exc_type) !== null && S !== void 0 ? S : "" }); })]; }); }); }, a.prototype.getSingleValue = function(l, o) { return e(this, void 0, void 0, function() { var d; return n(this, function(h) { return d = { doctype: l, field: o }, [2, this.axios.get("/api/method/frappe.client.get_single_value", { params: d }).then(function(f) { return f.data; }).catch(function(f) { var y, _; throw t(t({}, f.response.data), { httpStatus: f.response.status, httpStatusText: f.response.statusText, message: "There was an error while getting the value of single doctype.", exception: (_ = (y = f.response.data.exception) !== null && y !== void 0 ? y : f.response.data.exc_type) !== null && _ !== void 0 ? _ : "" }); })]; }); }); }, a.prototype.submit = function(l) { return e(this, void 0, void 0, function() { return n(this, function(o) { return [2, this.axios.post("/api/method/frappe.client.submit", { doc: l }).then(function(d) { return d.data.message; }).catch(function(d) { var h, f; throw t(t({}, d.response.data), { httpStatus: d.response.status, httpStatusText: d.response.statusText, message: "There was an error while submitting the document.", exception: (f = (h = d.response.data.exception) !== null && h !== void 0 ? h : d.response.data.exc_type) !== null && f !== void 0 ? f : "" }); })]; }); }); }, a.prototype.cancel = function(l, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/method/frappe.client.cancel", { doctype: l, name: o }).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while cancelling the document.", exception: (y = (f = h.response.data.exception) !== null && f !== void 0 ? f : h.response.data.exc_type) !== null && y !== void 0 ? y : "" }); })]; }); }); }, a; }() ); return ke.FrappeDB = r, ke; } var Fe = {}, Xe = {}; /*! Axios v1.16.0 Copyright (c) 2026 Matt Zabriskie and contributors */ var qn, Zs; function io() { if (Zs) return qn; Zs = 1; function t(s, i) { return function() { return s.apply(i, arguments); }; } const { toString: e } = Object.prototype, { getPrototypeOf: n } = Object, { iterator: r, toStringTag: a } = Symbol, l = /* @__PURE__ */ ((s) => (i) => { const c = e.call(i); return s[c] || (s[c] = c.slice(8, -1).toLowerCase()); })(/* @__PURE__ */ Object.create(null)), o = (s) => (s = s.toLowerCase(), (i) => l(i) === s), d = (s) => (i) => typeof i === s, { isArray: h } = Array, f = d("undefined"); function y(s) { return s !== null && !f(s) && s.constructor !== null && !f(s.constructor) && E(s.constructor.isBuffer) && s.constructor.isBuffer(s); } const _ = o("ArrayBuffer"); function S(s) { let i; return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? i = ArrayBuffer.isView(s) : i = s && s.buffer && _(s.buffer), i; } const m = d("string"), E = d("function"), x = d("number"), F = (s) => s !== null && typeof s == "object", J = (s) => s === !0 || s === !1, D = (s) => { if (l(s) !== "object") return !1; const i = n(s); return (i === null || i === Object.prototype || Object.getPrototypeOf(i) === null) && !(a in s) && !(r in s); }, Z = (s) => { if (!F(s) || y(s)) return !1; try { return Object.keys(s).length === 0 && Object.getPrototypeOf(s) === Object.prototype; } catch { return !1; } }, Y = o("Date"), I = o("File"), ie = (s) => !!(s && typeof s.uri < "u"), be = (s) => s && typeof s.getParts < "u", X = o("Blob"), M = o("FileList"), ee = (s) => F(s) && E(s.pipe); function se() { return typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof Un < "u" ? Un : {}; } const Se = se(), ge = typeof Se.FormData < "u" ? Se.FormData : void 0, re = (s) => { if (!s) return !1; if (ge && s instanceof ge) return !0; const i = n(s); if (!i || i === Object.prototype || !E(s.append)) return !1; const c = l(s); return c === "formdata" || // detect form-data instance c === "object" && E(s.toString) && s.toString() === "[object FormData]"; }, _e = o("URLSearchParams"), [Re, he, Ne, Ze] = [ "ReadableStream", "Request", "Response", "Headers" ].map(o), je = (s) => s.trim ? s.trim() : s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); function Je(s, i, { allOwnKeys: c = !1 } = {}) { if (s === null || typeof s > "u") return; let u, p; if (typeof s != "object" && (s = [s]), h(s)) for (u = 0, p = s.length; u < p; u++) i.call(null, s[u], u, s); else { if (y(s)) return; const g = c ? Object.getOwnPropertyNames(s) : Object.keys(s), w = g.length; let v; for (u = 0; u < w; u++) v = g[u], i.call(null, s[v], v, s); } } function de(s, i) { if (y(s)) return null; i = i.toLowerCase(); const c = Object.keys(s); let u = c.length, p; for (; u-- > 0; ) if (p = c[u], i === p.toLowerCase()) return p; return null; } const pe = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : Un, Me = (s) => !f(s) && s !== pe; function et(...s) { const { caseless: i, skipUndefined: c } = Me(this) && this || {}, u = {}, p = (g, w) => { if (w === "__proto__" || w === "constructor" || w === "prototype") return; const v = i && de(u, w) || w, T = H(u, v) ? u[v] : void 0; D(T) && D(g) ? u[v] = et(T, g) : D(g) ? u[v] = et({}, g) : h(g) ? u[v] = g.slice() : (!c || !f(g)) && (u[v] = g); }; for (let g = 0, w = s.length; g < w; g++) s[g] && Je(s[g], p); return u; } const tt = (s, i, c, { allOwnKeys: u } = {}) => (Je( i, (p, g) => { c && E(p) ? Object.defineProperty(s, g, { // Null-proto descriptor so a polluted Object.prototype.get cannot // hijack defineProperty's accessor-vs-data resolution. __proto__: null, value: t(p, c), writable: !0, enumerable: !0, configurable: !0 }) : Object.defineProperty(s, g, { __proto__: null, value: p, writable: !0, enumerable: !0, configurable: !0 }); }, { allOwnKeys: u } ), s), Ke = (s) => (s.charCodeAt(0) === 65279 && (s = s.slice(1)), s), at = (s, i, c, u) => { s.prototype = Object.create(i.prototype, u), Object.defineProperty(s.prototype, "constructor", { __proto__: null, value: s, writable: !0, enumerable: !1, configurable: !0 }), Object.defineProperty(s, "super", { __proto__: null, value: i.prototype }), c && Object.assign(s.prototype, c); }, gn = (s, i, c, u) => { let p, g, w; const v = {}; if (i = i || {}, s == null) return i; do { for (p = Object.getOwnPropertyNames(s), g = p.length; g-- > 0; ) w = p[g], (!u || u(w, s, i)) && !v[w] && (i[w] = s[w], v[w] = !0); s = c !== !1 && n(s); } while (s && (!c || c(s, i)) && s !== Object.prototype); return i; }, Mt = (s, i, c) => { s = String(s), (c === void 0 || c > s.length) && (c = s.length), c -= i.length; const u = s.indexOf(i, c); return u !== -1 && u === c; }, Vt = (s) => { if (!s) return null; if (h(s)) return s; let i = s.length; if (!x(i)) return null; const c = new Array(i); for (; i-- > 0; ) c[i] = s[i]; return c; }, wn = /* @__PURE__ */ ((s) => (i) => s && i instanceof s)(typeof Uint8Array < "u" && n(Uint8Array)), bn = (s, i) => { const u = (s && s[r]).call(s); let p; for (; (p = u.next()) && !p.done; ) { const g = p.value; i.call(s, g[0], g[1]); } }, ct = (s, i) => { let c; const u = []; for (; (c = s.exec(i)) !== null; ) u.push(c); return u; }, $t = o("HTMLFormElement"), vs = (s) => s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function(c, u, p) { return u.toUpperCase() + p; }), H = (({ hasOwnProperty: s }) => (i, c) => s.call(i, c))(Object.prototype), te = o("RegExp"), Q = (s, i) => { const c = Object.getOwnPropertyDescriptors(s), u = {}; Je(c, (p, g) => { let w; (w = i(p, g, s)) !== !1 && (u[g] = w || p); }), Object.defineProperties(s, u); }, ne = (s) => { Q(s, (i, c) => { if (E(s) && ["arguments", "caller", "callee"].includes(c)) return !1; const u = s[c]; if (E(u)) { if (i.enumerable = !1, "writable" in i) { i.writable = !1; return; } i.set || (i.set = () => { throw Error("Can not rewrite read-only method '" + c + "'"); }); } }); }, Te = (s, i) => { const c = {}, u = (p) => { p.forEach((g) => { c[g] = !0; }); }; return h(s) ? u(s) : u(String(s).split(i)), c; }, ve = () => { }, oe = (s, i) => s != null && Number.isFinite(s = +s) ? s : i; function Oe(s) { return !!(s && E(s.append) && s[a] === "FormData" && s[r]); } const ut = (s) => { const i = new Array(10), c = (u, p) => { if (F(u)) { if (i.indexOf(u) >= 0) return; if (y(u)) return u; if (!("toJSON" in u)) { i[p] = u; const g = h(u) ? [] : {}; return Je(u, (w, v) => { const T = c(w, p + 1); !f(T) && (g[v] = T); }), i[p] = void 0, g; } } return u; }; return c(s, 0); }, lt = o("AsyncFunction"), Ht = (s) => s && (F(s) || E(s)) && E(s.then) && E(s.catch), Ot = ((s, i) => s ? setImmediate : i ? ((c, u) => (pe.addEventListener( "message", ({ source: p, data: g }) => { p === pe && g === c && u.length && u.shift()(); }, !1 ), (p) => { u.push(p), pe.postMessage(c, "*"); }))(`axios@${Math.random()}`, []) : (c) => setTimeout(c))(typeof setImmediate == "function", E(pe.postMessage)), Ee = typeof queueMicrotask < "u" ? queueMicrotask.bind(pe) : typeof process < "u" && process.nextTick || Ot; var b = { isArray: h, isArrayBuffer: _, isBuffer: y, isFormData: re, isArrayBufferView: S, isString: m, isNumber: x, isBoolean: J, isObject: F, isPlainObject: D, isEmptyObject: Z, isReadableStream: Re, isRequest: he, isResponse: Ne, isHeaders: Ze, isUndefined: f, isDate: Y, isFile: I, isReactNativeBlob: ie, isReactNative: be, isBlob: X, isRegExp: te, isFunction: E, isStream: ee, isURLSearchParams: _e, isTypedArray: wn, isFileList: M, forEach: Je, merge: et, extend: tt, trim: je, stripBOM: Ke, inherits: at, toFlatObject: gn, kindOf: l, kindOfTest: o, endsWith: Mt, toArray: Vt, forEachEntry: bn, matchAll: ct, isHTMLForm: $t, hasOwnProperty: H, hasOwnProp: H, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: Q, freezeMethods: ne, toObjectSet: Te, toCamelCase: vs, noop: ve, toFiniteNumber: oe, findKey: de, global: pe, isContextDefined: Me, isSpecCompliantForm: Oe, toJSONObject: ut, isAsyncFn: lt, isThenable: Ht, setImmediate: Ot, asap: Ee, isIterable: (s) => s != null && E(s[r]) }; const _n = b.toObjectSet([ "age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent" ]); var Tt = (s) => { const i = {}; let c, u, p; return s && s.split(` `).forEach(function(w) { p = w.indexOf(":"), c = w.substring(0, p).trim().toLowerCase(), u = w.substring(p + 1).trim(), !(!c || i[c] && _n[c]) && (c === "set-cookie" ? i[c] ? i[c].push(u) : i[c] = [u] : i[c] = i[c] ? i[c] + ", " + u : u); }), i; }; const Es = Symbol("internals"), si = /[^\x09\x20-\x7E\x80-\xFF]/g; function ri(s) { let i = 0, c = s.length; for (; i < c; ) { const u = s.charCodeAt(i); if (u !== 9 && u !== 32) break; i += 1; } for (; c > i; ) { const u = s.charCodeAt(c - 1); if (u !== 9 && u !== 32) break; c -= 1; } return i === 0 && c === s.length ? s : s.slice(i, c); } function xt(s) { return s && String(s).trim().toLowerCase(); } function ii(s) { return ri(s.replace(si, "")); } function Wt(s) { return s === !1 || s == null ? s : b.isArray(s) ? s.map(Wt) : ii(String(s)); } function oi(s) { const i = /* @__PURE__ */ Object.create(null), c = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let u; for (; u = c.exec(s); ) i[u[1]] = u[2]; return i; } const ai = (s) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim()); function vn(s, i, c, u, p) { if (b.isFunction(u)) return u.call(this, i, c); if (p && (i = c), !!b.isString(i)) { if (b.isString(u)) return i.indexOf(u) !== -1; if (b.isRegExp(u)) return u.test(i); } } function ci(s) { return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (i, c, u) => c.toUpperCase() + u); } function ui(s, i) { const c = b.toCamelCase(" " + i); ["get", "set", "has"].forEach((u) => { Object.defineProperty(s, u + c, { // Null-proto descriptor so a polluted Object.prototype.get cannot turn // this data descriptor into an accessor descriptor on the way in. __proto__: null, value: function(p, g, w) { return this[u].call(this, i, p, g, w); }, configurable: !0 }); }); } class we { constructor(i) { i && this.set(i); } set(i, c, u) { const p = this; function g(v, T, O) { const R = xt(T); if (!R) throw new Error("header name must be a non-empty string"); const P = b.findKey(p, R); (!P || p[P] === void 0 || O === !0 || O === void 0 && p[P] !== !1) && (p[P || T] = Wt(v)); } const w = (v, T) => b.forEach(v, (O, R) => g(O, R, T)); if (b.isPlainObject(i) || i instanceof this.constructor) w(i, c); else if (b.isString(i) && (i = i.trim()) && !ai(i)) w(Tt(i), c); else if (b.isObject(i) && b.isIterable(i)) { let v = {}, T, O; for (const R of i) { if (!b.isArray(R)) throw TypeError("Object iterator must return a key-value pair"); v[O = R[0]] = (T = v[O]) ? b.isArray(T) ? [...T, R[1]] : [T, R[1]] : R[1]; } w(v, c); } else i != null && g(c, i, u); return this; } get(i, c) { if (i = xt(i), i) { const u = b.findKey(this, i); if (u) { const p = this[u]; if (!c) return p; if (c === !0) return oi(p); if (b.isFunction(c)) return c.call(this, p, u); if (b.isRegExp(c)) return c.exec(p); throw new TypeError("parser must be boolean|regexp|function"); } } } has(i, c) { if (i = xt(i), i) { const u = b.findKey(this, i); return !!(u && this[u] !== void 0 && (!c || vn(this, this[u], u, c))); } return !1; } delete(i, c) { const u = this; let p = !1; function g(w) { if (w = xt(w), w) { const v = b.findKey(u, w); v && (!c || vn(u, u[v], v, c)) && (delete u[v], p = !0); } } return b.isArray(i) ? i.forEach(g) : g(i), p; } clear(i) { const c = Object.keys(this); let u = c.length, p = !1; for (; u--; ) { const g = c[u]; (!i || vn(this, this[g], g, i, !0)) && (delete this[g], p = !0); } return p; } normalize(i) { const c = this, u = {}; return b.forEach(this, (p, g) => { const w = b.findKey(u, g); if (w) { c[w] = Wt(p), delete c[g]; return; } const v = i ? ci(g) : String(g).trim(); v !== g && delete c[g], c[v] = Wt(p), u[v] = !0; }), this; } concat(...i) { return this.constructor.concat(this, ...i); } toJSON(i) { const c = /* @__PURE__ */ Object.create(null); return b.forEach(this, (u, p) => { u != null && u !== !1 && (c[p] = i && b.isArray(u) ? u.join(", ") : u); }), c; } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator](); } toString() { return Object.entries(this.toJSON()).map(([i, c]) => i + ": " + c).join(` `); } getSetCookie() { return this.get("set-cookie") || []; } get [Symbol.toStringTag]() { return "AxiosHeaders"; } static from(i) { return i instanceof this ? i : new this(i); } static concat(i, ...c) { const u = new this(i); return c.forEach((p) => u.set(p)), u; } static accessor(i) { const u = (this[Es] = this[Es] = { accessors: {} }).accessors, p = this.prototype; function g(w) { const v = xt(w); u[v] || (ui(p, w), u[v] = !0); } return b.isArray(i) ? i.forEach(g) : g(i), this; } } we.accessor([ "Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization" ]), b.reduceDescriptors(we.prototype, ({ value: s }, i) => { let c = i[0].toUpperCase() + i.slice(1); return { get: () => s, set(u) { this[c] = u; } }; }), b.freezeMethods(we); const li = "[REDACTED ****]"; function fi(s) { if (b.hasOwnProp(s, "toJSON")) return !0; let i = Object.getPrototypeOf(s); for (; i && i !== Object.prototype; ) { if (b.hasOwnProp(i, "toJSON")) return !0; i = Object.getPrototypeOf(i); } return !1; } function hi(s, i) { const c = new Set(i.map((g) => String(g).toLowerCase())), u = [], p = (g) => { if (g === null || typeof g != "object" || b.isBuffer(g)) return g; if (u.indexOf(g) !== -1) return; g instanceof we && (g = g.toJSON()), u.push(g); let w; if (b.isArray(g)) w = [], g.forEach((v, T) => { const O = p(v); b.isUndefined(O) || (w[T] = O); }); else { if (!b.isPlainObject(g) && fi(g)) return u.pop(), g; w = /* @__PURE__ */ Object.create(null); for (const [v, T] of Object.entries(g)) { const O = c.has(v.toLowerCase()) ? li : p(T); b.isUndefined(O) || (w[v] = O); } } return u.pop(), w; }; return p(s); } class C extends Error { static from(i, c, u, p, g, w) { const v = new C(i.message, c || i.code, u, p, g); return v.cause = i, v.name = i.name, i.status != null && v.status == null && (v.status = i.status), w && Object.assign(v, w), v; } /** * Create an Error with the specified message, config, error code, request and response. * * @param {string} message The error message. * @param {string} [code] The error code (for example, 'ECONNABORTED'). * @param {Object} [config] The config. * @param {Object} [request] The request. * @param {Object} [response] The response. * * @returns {Error} The created error. */ constructor(i, c, u, p, g) { super(i), Object.defineProperty(this, "message", { // Null-proto descriptor so a polluted Object.prototype.get cannot turn // this data descriptor into an accessor descriptor on the way in. __proto__: null, value: i, enumerable: !0, writable: !0, configurable: !0 }), this.name = "AxiosError", this.isAxiosError = !0, c && (this.code = c), u && (this.config = u), p && (this.request = p), g && (this.response = g, this.status = g.status); } toJSON() { const i = this.config, c = i && b.hasOwnProp(i, "redact") ? i.redact : void 0, u = b.isArray(c) && c.length > 0 ? hi(i, c) : b.toJSONObject(i); return { // Standard message: this.message, name: this.name, // Microsoft description: this.description, number: this.number, // Mozilla fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, // Axios config: u, code: this.code, status: this.status }; } } C.ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE", C.ERR_BAD_OPTION = "ERR_BAD_OPTION", C.ECONNABORTED = "ECONNABORTED", C.ETIMEDOUT = "ETIMEDOUT", C.ECONNREFUSED = "ECONNREFUSED", C.ERR_NETWORK = "ERR_NETWORK", C.ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS", C.ERR_DEPRECATED = "ERR_DEPRECATED", C.ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE", C.ERR_BAD_REQUEST = "ERR_BAD_REQUEST", C.ERR_CANCELED = "ERR_CANCELED", C.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT", C.ERR_INVALID_URL = "ERR_INVALID_URL", C.ERR_FORM_DATA_DEPTH_EXCEEDED = "ERR_FORM_DATA_DEPTH_EXCEEDED"; var di = null; function En(s) { return b.isPlainObject(s) || b.isArray(s); } function Ss(s) { return b.endsWith(s, "[]") ? s.slice(0, -2) : s; } function Sn(s, i, c) { return s ? s.concat(i).map(function(p, g) { return p = Ss(p), !c && g ? "[" + p + "]" : p; }).join(c ? "." : "") : i; } function pi(s) { return b.isArray(s) && !s.some(En); } const yi = b.toFlatObject(b, {}, null, function(i) { return /^is[A-Z]/.test(i); }); function zt(s, i, c) { if (!b.isObject(s)) throw new TypeError("target must be an object"); i = i || new FormData(), c = b.toFlatObject( c, { metaTokens: !0, dots: !1, indexes: !1 }, !1, function(A, N) { return !b.isUndefined(N[A]); } ); const u = c.metaTokens, p = c.visitor || P, g = c.dots, w = c.indexes, v = c.Blob || typeof Blob < "u" && Blob, T = c.maxDepth === void 0 ? 100 : c.maxDepth, O = v && b.isSpecCompliantForm(i); if (!b.isFunction(p)) throw new TypeError("visitor must be a function"); function R(L) { if (L === null) return ""; if (b.isDate(L)) return L.toISOString(); if (b.isBoolean(L)) return L.toString(); if (!O && b.isBlob(L)) throw new C("Blob is not supported. Use a Buffer instead."); return b.isArrayBuffer(L) || b.isTypedArray(L) ? O && typeof Blob == "function" ? new Blob([L]) : Buffer.from(L) : L; } function P(L, A, N) { let K = L; if (b.isReactNative(i) && b.isReactNativeBlob(L)) return i.append(Sn(N, A, g), R(L)), !1; if (L && !N && typeof L == "object") { if (b.endsWith(A, "{}")) A = u ? A : A.slice(0, -2), L = JSON.stringify(L); else if (b.isArray(L) && pi(L) || (b.isFileList(L) || b.endsWith(A, "[]")) && (K = b.toArray(L))) return A = Ss(A), K.forEach(function($, Ae) { !(b.isUndefined($) || $ === null) && i.append( // eslint-disable-next-line no-nested-ternary w === !0 ? Sn([A], Ae, g) : w === null ? A : A + "[]", R($) ); }), !1; } return En(L) ? !0 : (i.append(Sn(N, A, g), R(L)), !1); } const j = [], B = Object.assign(yi, { defaultVisitor: P, convertValue: R, isVisitable: En }); function U(L, A, N = 0) { if (!b.isUndefined(L)) { if (N > T) throw new C( "Object is too deeply nested (" + N + " levels). Max depth: " + T, C.ERR_FORM_DATA_DEPTH_EXCEEDED ); if (j.indexOf(L) !== -1) throw Error("Circular reference detected in " + A.join(".")); j.push(L), b.forEach(L, function(W, $) { (!(b.isUndefined(W) || W === null) && p.call(i, W, b.isString($) ? $.trim() : $, A, B)) === !0 && U(W, A ? A.concat($) : [$], N + 1); }), j.pop(); } } if (!b.isObject(s)) throw new TypeError("data must be an object"); return U(s), i; } function Rs(s) { const i = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+" }; return encodeURIComponent(s).replace(/[!'()~]|%20/g, function(u) { return i[u]; }); } function Rn(s, i) { this._pairs = [], s && zt(s, this, i); } const Os = Rn.prototype; Os.append = function(i, c) { this._pairs.push([i, c]); }, Os.toString = function(i) { const c = i ? function(u) { return i.call(this, u, Rs); } : Rs; return this._pairs.map(function(p) { return c(p[0]) + "=" + c(p[1]); }, "").join("&"); }; function mi(s) { return encodeURIComponent(s).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+"); } function Ts(s, i, c) { if (!i) return s; const u = c && c.encode || mi, p = b.isFunction(c) ? { serialize: c } : c, g = p && p.serialize; let w; if (g ? w = g(i, p) : w = b.isURLSearchParams(i) ? i.toString() : new Rn(i, p).toString(u), w) { const v = s.indexOf("#"); v !== -1 && (s = s.slice(0, v)), s += (s.indexOf("?") === -1 ? "?" : "&") + w; } return s; } class xs { constructor() { this.handlers = []; } /** * Add a new interceptor to the stack * * @param {Function} fulfilled The function to handle `then` for a `Promise` * @param {Function} rejected The function to handle `reject` for a `Promise` * @param {Object} options The options for the interceptor, synchronous and runWhen * * @return {Number} An ID used to remove interceptor later */ use(i, c, u) { return this.handlers.push({ fulfilled: i, rejected: c, synchronous: u ? u.synchronous : !1, runWhen: u ? u.runWhen : null }), this.handlers.length - 1; } /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` * * @returns {void} */ eject(i) { this.handlers[i] && (this.handlers[i] = null); } /** * Clear all interceptors from the stack * * @returns {void} */ clear() { this.handlers && (this.handlers = []); } /** * Iterate over all the registered interceptors * * This method is particularly useful for skipping over any * interceptors that may have become `null` calling `eject`. * * @param {Function} fn The function to call for each interceptor * * @returns {void} */ forEach(i) { b.forEach(this.handlers, function(u) { u !== null && i(u); }); } } var On = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1, legacyInterceptorReqResOrdering: !0 }, gi = typeof URLSearchParams < "u" ? URLSearchParams : Rn, wi = typeof FormData < "u" ? FormData : null, bi = typeof Blob < "u" ? Blob : null, _i = { isBrowser: !0, classes: { URLSearchParams: gi, FormData: wi, Blob: bi }, protocols: ["http", "https", "file", "blob", "url", "data"] }; const Tn = typeof window < "u" && typeof document < "u", xn = typeof navigator == "object" && navigator || void 0, vi = Tn && (!xn || ["ReactNative", "NativeScript", "NS"].indexOf(xn.product) < 0), Ei = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Si = Tn && window.location.href || "http://localhost"; var Ri = /* @__PURE__ */ Object.freeze({ __proto__: null, hasBrowserEnv: Tn, hasStandardBrowserEnv: vi, hasStandardBrowserWebWorkerEnv: Ei, navigator: xn, origin: Si }), ye = { ...Ri, ..._i }; function Oi(s, i) { return zt(s, new ye.classes.URLSearchParams(), { visitor: function(c, u, p, g) { return ye.isNode && b.isBuffer(c) ? (this.append(u, c.toString("base64")), !1) : g.defaultVisitor.apply(this, arguments); }, ...i }); } function Ti(s) { return b.matchAll(/\w+|\[(\w*)]/g, s).map((i) => i[0] === "[]" ? "" : i[1] || i[0]); } function xi(s) { const i = {}, c = Object.keys(s); let u; const p = c.length; let g; for (u = 0; u < p; u++) g = c[u], i[g] = s[g]; return i; } function As(s) { function i(c, u, p, g) { let w = c[g++]; if (w === "__proto__") return !0; const v = Number.isFinite(+w), T = g >= c.length; return w = !w && b.isArray(p) ? p.length : w, T ? (b.hasOwnProp(p, w) ? p[w] = b.isArray(p[w]) ? p[w].concat(u) : [p[w], u] : p[w] = u, !v) : ((!p[w] || !b.isObject(p[w])) && (p[w] = []), i(c, u, p[w], g) && b.isArray(p[w]) && (p[w] = xi(p[w])), !v); } if (b.isFormData(s) && b.isFunction(s.entries)) { const c = {}; return b.forEachEntry(s, (u, p) => { i(Ti(u), p, c, 0); }), c; } return null; } const wt = (s, i) => s != null && b.hasOwnProp(s, i) ? s[i] : void 0; function Ai(s, i, c) { if (b.isString(s)) try { return (i || JSON.parse)(s), b.trim(s); } catch (u) { if (u.name !== "SyntaxError") throw u; } return (c || JSON.stringify)(s); } const At = { transitional: On, adapter: ["xhr", "http", "fetch"], transformRequest: [ function(i, c) { const u = c.getContentType() || "", p = u.indexOf("application/json") > -1, g = b.isObject(i); if (g && b.isHTMLForm(i) && (i = new FormData(i)), b.isFormData(i)) return p ? JSON.stringify(As(i)) : i; if (b.isArrayBuffer(i) || b.isBuffer(i) || b.isStream(i) || b.isFile(i) || b.isBlob(i) || b.isReadableStream(i)) return i; if (b.isArrayBufferView(i)) return i.buffer; if (b.isURLSearchParams(i)) return c.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), i.toString(); let v; if (g) { const T = wt(this, "formSerializer"); if (u.indexOf("application/x-www-form-urlencoded") > -1) return Oi(i, T).toString(); if ((v = b.isFileList(i)) || u.indexOf("multipart/form-data") > -1) { const O = wt(this, "env"), R = O && O.FormData; return zt( v ? { "files[]": i } : i, R && new R(), T ); } } return g || p ? (c.setContentType("application/json", !1), Ai(i)) : i; } ], transformRespon