UNPKG

frappe-react-sdk

Version:
1,365 lines (1,364 loc) 193 kB
var _i = Object.defineProperty; var vi = (t, e, n) => e in t ? _i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var ze = (t, e, n) => vi(t, typeof e != "symbol" ? e + "" : e, n); import { jsx as Es } from "react/jsx-runtime"; import bt, { createContext as Xs, useContext as Z, useMemo as Kt, useRef as Pe, useEffect as at, useLayoutEffect as Ei, createElement as Si, useCallback as I, useDebugValue as Ri, useState as V } from "react"; var Ti = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, et = {}, pt = {}, Oe = {}, Ss; function Ys() { if (Ss) return Oe; Ss = 1; var t = Oe && Oe.__assign || function() { return t = Object.assign || function(a) { for (var c, o = 1, d = arguments.length; o < d; o++) { c = arguments[o]; for (var h in c) Object.prototype.hasOwnProperty.call(c, h) && (a[h] = c[h]); } return a; }, t.apply(this, arguments); }, e = Oe && Oe.__awaiter || function(a, c, o, d) { function h(u) { return u instanceof o ? u : new o(function(m) { m(u); }); } return new (o || (o = Promise))(function(u, m) { function b(v) { try { p(d.next(v)); } catch (R) { m(R); } } function E(v) { try { p(d.throw(v)); } catch (R) { m(R); } } function p(v) { v.done ? u(v.value) : h(v.value).then(b, E); } p((d = d.apply(a, c || [])).next()); }); }, n = Oe && Oe.__generator || function(a, c) { var o = { label: 0, sent: function() { if (u[0] & 1) throw u[1]; return u[1]; }, trys: [], ops: [] }, d, h, u, m; return m = { next: b(0), throw: b(1), return: b(2) }, typeof Symbol == "function" && (m[Symbol.iterator] = function() { return this; }), m; function b(p) { return function(v) { return E([p, v]); }; } function E(p) { if (d) throw new TypeError("Generator is already executing."); for (; m && (m = 0, p[0] && (o = 0)), o; ) try { if (d = 1, h && (u = p[0] & 2 ? h.return : p[0] ? h.throw || ((u = h.return) && u.call(h), 0) : h.next) && !(u = u.call(h, p[1])).done) return u; switch (h = 0, u && (p = [p[0] & 2, u.value]), p[0]) { case 0: case 1: u = p; break; case 4: return o.label++, { value: p[1], done: !1 }; case 5: o.label++, h = p[1], p = [0]; continue; case 7: p = o.ops.pop(), o.trys.pop(); continue; default: if (u = o.trys, !(u = u.length > 0 && u[u.length - 1]) && (p[0] === 6 || p[0] === 2)) { o = 0; continue; } if (p[0] === 3 && (!u || p[1] > u[0] && p[1] < u[3])) { o.label = p[1]; break; } if (p[0] === 6 && o.label < u[1]) { o.label = u[1], u = p; break; } if (u && o.label < u[2]) { o.label = u[2], o.ops.push(p); break; } u[2] && o.ops.pop(), o.trys.pop(); continue; } p = c.call(a, o); } catch (v) { p = [6, v], h = 0; } finally { d = u = 0; } if (p[0] & 5) throw p[1]; return { value: p[0] ? p[1] : void 0, done: !0 }; } }; Object.defineProperty(Oe, "__esModule", { value: !0 }), Oe.FrappeCall = void 0; var s = ( /** @class */ function() { function a(c, o, d, h, u) { this.appURL = c, this.axios = o, this.useToken = d ?? !1, this.token = h, this.tokenType = u; } return a.prototype.get = function(c, 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(u) { var m = u[0], b = u[1]; if (b != null) { var E = typeof b == "object" ? JSON.stringify(b) : b; d.set(m, E); } }), [2, this.axios.get("/api/method/".concat(c), { params: d }).then(function(u) { return u.data; }).catch(function(u) { var m, b; throw t(t({}, u.response.data), { httpStatus: u.response.status, httpStatusText: u.response.statusText, message: (m = u.response.data.message) !== null && m !== void 0 ? m : "There was an error.", exception: (b = u.response.data.exception) !== null && b !== void 0 ? b : "" }); })]; }); }); }, a.prototype.post = function(c, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/method/".concat(c), t({}, o)).then(function(h) { return h.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (u = h.response.data.message) !== null && u !== void 0 ? u : "There was an error.", exception: (m = h.response.data.exception) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a.prototype.put = function(c, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.put("/api/method/".concat(c), t({}, o)).then(function(h) { return h.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (u = h.response.data.message) !== null && u !== void 0 ? u : "There was an error.", exception: (m = h.response.data.exception) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a.prototype.delete = function(c, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/method/".concat(c), { params: o }).then(function(h) { return h.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (u = h.response.data.message) !== null && u !== void 0 ? u : "There was an error.", exception: (m = h.response.data.exception) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a; }() ); return Oe.FrappeCall = s, Oe; } var xe = {}, Rs; function Qs() { if (Rs) return xe; Rs = 1; var t = xe && xe.__assign || function() { return t = Object.assign || function(a) { for (var c, o = 1, d = arguments.length; o < d; o++) { c = arguments[o]; for (var h in c) Object.prototype.hasOwnProperty.call(c, h) && (a[h] = c[h]); } return a; }, t.apply(this, arguments); }, e = xe && xe.__awaiter || function(a, c, o, d) { function h(u) { return u instanceof o ? u : new o(function(m) { m(u); }); } return new (o || (o = Promise))(function(u, m) { function b(v) { try { p(d.next(v)); } catch (R) { m(R); } } function E(v) { try { p(d.throw(v)); } catch (R) { m(R); } } function p(v) { v.done ? u(v.value) : h(v.value).then(b, E); } p((d = d.apply(a, c || [])).next()); }); }, n = xe && xe.__generator || function(a, c) { var o = { label: 0, sent: function() { if (u[0] & 1) throw u[1]; return u[1]; }, trys: [], ops: [] }, d, h, u, m; return m = { next: b(0), throw: b(1), return: b(2) }, typeof Symbol == "function" && (m[Symbol.iterator] = function() { return this; }), m; function b(p) { return function(v) { return E([p, v]); }; } function E(p) { if (d) throw new TypeError("Generator is already executing."); for (; m && (m = 0, p[0] && (o = 0)), o; ) try { if (d = 1, h && (u = p[0] & 2 ? h.return : p[0] ? h.throw || ((u = h.return) && u.call(h), 0) : h.next) && !(u = u.call(h, p[1])).done) return u; switch (h = 0, u && (p = [p[0] & 2, u.value]), p[0]) { case 0: case 1: u = p; break; case 4: return o.label++, { value: p[1], done: !1 }; case 5: o.label++, h = p[1], p = [0]; continue; case 7: p = o.ops.pop(), o.trys.pop(); continue; default: if (u = o.trys, !(u = u.length > 0 && u[u.length - 1]) && (p[0] === 6 || p[0] === 2)) { o = 0; continue; } if (p[0] === 3 && (!u || p[1] > u[0] && p[1] < u[3])) { o.label = p[1]; break; } if (p[0] === 6 && o.label < u[1]) { o.label = u[1], u = p; break; } if (u && o.label < u[2]) { o.label = u[2], o.ops.push(p); break; } u[2] && o.ops.pop(), o.trys.pop(); continue; } p = c.call(a, o); } catch (v) { p = [6, v], h = 0; } finally { d = u = 0; } if (p[0] & 5) throw p[1]; return { value: p[0] ? p[1] : void 0, done: !0 }; } }; Object.defineProperty(xe, "__esModule", { value: !0 }), xe.FrappeDB = void 0; var s = ( /** @class */ function() { function a(c, o, d, h, u) { this.appURL = c, this.axios = o, this.useToken = d ?? !1, this.token = h, this.tokenType = u; } return a.prototype.getDoc = function(c, 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(c, "/").concat(encodeURIComponent(o))).then(function(h) { return h.data.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while fetching the document.", exception: (m = (u = h.response.data.exception) !== null && u !== void 0 ? u : h.response.data.exc_type) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a.prototype.getDocList = function(c, o) { var d; return e(this, void 0, void 0, function() { var h, u, m, b, E, p, v, R, q, x, X; return n(this, function(z) { return h = {}, o && (u = o.fields, m = o.filters, b = o.orFilters, E = o.orderBy, p = o.limit, v = o.limit_start, R = o.groupBy, q = o.asDict, x = q === void 0 ? !0 : q, X = E ? "".concat(String(E == null ? void 0 : E.field), " ").concat((d = E == null ? void 0 : E.order) !== null && d !== void 0 ? d : "asc") : "", h = { fields: u ? JSON.stringify(u) : void 0, filters: m ? JSON.stringify(m) : void 0, or_filters: b ? JSON.stringify(b) : void 0, order_by: X, group_by: R, limit: p, limit_start: v, as_dict: x }), [2, this.axios.get("/api/resource/".concat(c), { params: h }).then(function(H) { return H.data.data; }).catch(function(H) { var U, J; throw t(t({}, H.response.data), { httpStatus: H.response.status, httpStatusText: H.response.statusText, message: "There was an error while fetching the documents.", exception: (J = (U = H.response.data.exception) !== null && U !== void 0 ? U : H.response.data.exc_type) !== null && J !== void 0 ? J : "" }); })]; }); }); }, a.prototype.createDoc = function(c, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/resource/".concat(c), t({}, o)).then(function(h) { return h.data.data; }).catch(function(h) { var u, m, b; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (u = h.response.data.message) !== null && u !== void 0 ? u : "There was an error while creating the document.", exception: (b = (m = h.response.data.exception) !== null && m !== void 0 ? m : h.response.data.exc_type) !== null && b !== void 0 ? b : "" }); })]; }); }); }, a.prototype.updateDoc = function(c, o, d) { return e(this, void 0, void 0, function() { return n(this, function(h) { return [2, this.axios.put("/api/resource/".concat(c, "/").concat(o && encodeURIComponent(o)), t({}, d)).then(function(u) { return u.data.data; }).catch(function(u) { var m, b, E; throw t(t({}, u.response.data), { httpStatus: u.response.status, httpStatusText: u.response.statusText, message: (m = u.response.data.message) !== null && m !== void 0 ? m : "There was an error while updating the document.", exception: (E = (b = u.response.data.exception) !== null && b !== void 0 ? b : u.response.data.exc_type) !== null && E !== void 0 ? E : "" }); })]; }); }); }, a.prototype.deleteDoc = function(c, o) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/resource/".concat(c, "/").concat(o && encodeURIComponent(o))).then(function(h) { return h.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while deleting the document.", exception: (m = (u = h.response.data.exception) !== null && u !== void 0 ? u : h.response.data.exc_type) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a.prototype.getCount = function(c, o, d, h) { return d === void 0 && (d = !1), h === void 0 && (h = !1), e(this, void 0, void 0, function() { var u; return n(this, function(m) { return u = { doctype: c, filters: [] }, d && (u.cache = d), h && (u.debug = h), o && (u.filters = o ? JSON.stringify(o) : void 0), [2, this.axios.get("/api/method/frappe.client.get_count", { params: u }).then(function(b) { return b.data.message; }).catch(function(b) { var E, p; throw t(t({}, b.response.data), { httpStatus: b.response.status, httpStatusText: b.response.statusText, message: "There was an error while getting the count.", exception: (p = (E = b.response.data.exception) !== null && E !== void 0 ? E : b.response.data.exc_type) !== null && p !== void 0 ? p : "" }); })]; }); }); }, a.prototype.getLastDoc = function(c, o) { return e(this, void 0, void 0, function() { var d, h; return n(this, function(u) { switch (u.label) { case 0: return d = { orderBy: { field: "creation", order: "desc" } }, o && (d = t(t({}, d), o)), [4, this.getDocList(c, t(t({}, d), { limit: 1, fields: ["name"] }))]; case 1: return h = u.sent(), h.length > 0 ? [2, this.getDoc(c, h[0].name)] : [2, {}]; } }); }); }, a.prototype.renameDoc = function(c, o, d, h) { return h === void 0 && (h = !1), e(this, void 0, void 0, function() { return n(this, function(u) { return [2, this.axios.post("/api/method/frappe.client.rename_doc", { doctype: c, old_name: o, new_name: d, merge: h }).then(function(m) { return m.data; }).catch(function(m) { var b, E, p; throw t(t({}, m.response.data), { httpStatus: m.response.status, httpStatusText: m.response.statusText, message: (b = m.response.data.message) !== null && b !== void 0 ? b : "There was an error while renaming the document.", exception: (p = (E = m.response.data.exception) !== null && E !== void 0 ? E : m.response.data.exc_type) !== null && p !== void 0 ? p : "" }); })]; }); }); }, a.prototype.getValue = function(c, o, d, h, u, m) { return h === void 0 && (h = !0), u === void 0 && (u = !1), m === void 0 && (m = null), e(this, void 0, void 0, function() { var b; return n(this, function(E) { return b = { doctype: c, fieldname: "[]", filters: [], as_dict: h, debug: u, parent: null }, o && (b.fieldname = typeof o == "object" ? JSON.stringify(o) : o), d && (b.filters = d ? JSON.stringify(d) : void 0), m && (b.parent = m), [2, this.axios.get("/api/method/frappe.client.get_value", { params: b }).then(function(p) { return p.data; }).catch(function(p) { var v, R; throw t(t({}, p.response.data), { httpStatus: p.response.status, httpStatusText: p.response.statusText, message: "There was an error while getting the value.", exception: (R = (v = p.response.data.exception) !== null && v !== void 0 ? v : p.response.data.exc_type) !== null && R !== void 0 ? R : "" }); })]; }); }); }, a.prototype.setValue = function(c, o, d, h) { return e(this, void 0, void 0, function() { return n(this, function(u) { return d !== null && typeof d == "object" && !Array.isArray(d) && (h = void 0), [2, this.axios.post("/api/method/frappe.client.set_value", { doctype: c, name: o, fieldname: d, value: h }).then(function(m) { return m.data; }).catch(function(m) { var b, E; throw t(t({}, m.response.data), { httpStatus: m.response.status, httpStatusText: m.response.statusText, message: "There was an error while setting the value.", exception: (E = (b = m.response.data.exception) !== null && b !== void 0 ? b : m.response.data.exc_type) !== null && E !== void 0 ? E : "" }); })]; }); }); }, a.prototype.getSingleValue = function(c, o) { return e(this, void 0, void 0, function() { var d; return n(this, function(h) { return d = { doctype: c, field: o }, [2, this.axios.get("/api/method/frappe.client.get_single_value", { params: d }).then(function(u) { return u.data; }).catch(function(u) { var m, b; throw t(t({}, u.response.data), { httpStatus: u.response.status, httpStatusText: u.response.statusText, message: "There was an error while getting the value of single doctype.", exception: (b = (m = u.response.data.exception) !== null && m !== void 0 ? m : u.response.data.exc_type) !== null && b !== void 0 ? b : "" }); })]; }); }); }, a.prototype.submit = function(c) { return e(this, void 0, void 0, function() { return n(this, function(o) { return [2, this.axios.post("/api/method/frappe.client.submit", { doc: c }).then(function(d) { return d.data.message; }).catch(function(d) { var h, u; throw t(t({}, d.response.data), { httpStatus: d.response.status, httpStatusText: d.response.statusText, message: "There was an error while submitting the document.", exception: (u = (h = d.response.data.exception) !== null && h !== void 0 ? h : d.response.data.exc_type) !== null && u !== void 0 ? u : "" }); })]; }); }); }, a.prototype.cancel = function(c, 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: c, name: o }).then(function(h) { return h.data; }).catch(function(h) { var u, m; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while cancelling the document.", exception: (m = (u = h.response.data.exception) !== null && u !== void 0 ? u : h.response.data.exc_type) !== null && m !== void 0 ? m : "" }); })]; }); }); }, a; }() ); return xe.FrappeDB = s, xe; } var Ae = {}, Ie = {}; /*! Axios v1.8.2 Copyright (c) 2025 Matt Zabriskie and contributors */ var pn, Ts; function Oi() { if (Ts) return pn; Ts = 1; function t(r, i) { return function() { return r.apply(i, arguments); }; } const { toString: e } = Object.prototype, { getPrototypeOf: n } = Object, s = /* @__PURE__ */ ((r) => (i) => { const l = e.call(i); return r[l] || (r[l] = l.slice(8, -1).toLowerCase()); })(/* @__PURE__ */ Object.create(null)), a = (r) => (r = r.toLowerCase(), (i) => s(i) === r), c = (r) => (i) => typeof i === r, { isArray: o } = Array, d = c("undefined"); function h(r) { return r !== null && !d(r) && r.constructor !== null && !d(r.constructor) && E(r.constructor.isBuffer) && r.constructor.isBuffer(r); } const u = a("ArrayBuffer"); function m(r) { let i; return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? i = ArrayBuffer.isView(r) : i = r && r.buffer && u(r.buffer), i; } const b = c("string"), E = c("function"), p = c("number"), v = (r) => r !== null && typeof r == "object", R = (r) => r === !0 || r === !1, q = (r) => { if (s(r) !== "object") return !1; const i = n(r); return (i === null || i === Object.prototype || Object.getPrototypeOf(i) === null) && !(Symbol.toStringTag in r) && !(Symbol.iterator in r); }, x = a("Date"), X = a("File"), z = a("Blob"), H = a("FileList"), U = (r) => v(r) && E(r.pipe), J = (r) => { let i; return r && (typeof FormData == "function" && r instanceof FormData || E(r.append) && ((i = s(r)) === "formdata" || // detect form-data instance i === "object" && E(r.toString) && r.toString() === "[object FormData]")); }, ke = a("URLSearchParams"), [N, pe, M, ce] = ["ReadableStream", "Request", "Response", "Headers"].map(a), be = (r) => r.trim ? r.trim() : r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); function G(r, i, { allOwnKeys: l = !1 } = {}) { if (r === null || typeof r > "u") return; let f, y; if (typeof r != "object" && (r = [r]), o(r)) for (f = 0, y = r.length; f < y; f++) i.call(null, r[f], f, r); else { const g = l ? Object.getOwnPropertyNames(r) : Object.keys(r), w = g.length; let S; for (f = 0; f < w; f++) S = g[f], i.call(null, r[S], S, r); } } function ue(r, i) { i = i.toLowerCase(); const l = Object.keys(r); let f = l.length, y; for (; f-- > 0; ) if (y = l[f], i === y.toLowerCase()) return y; return null; } const le = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : Ti, Ne = (r) => !d(r) && r !== le; function Y() { const { caseless: r } = Ne(this) && this || {}, i = {}, l = (f, y) => { const g = r && ue(i, y) || y; q(i[g]) && q(f) ? i[g] = Y(i[g], f) : q(f) ? i[g] = Y({}, f) : o(f) ? i[g] = f.slice() : i[g] = f; }; for (let f = 0, y = arguments.length; f < y; f++) arguments[f] && G(arguments[f], l); return i; } const ge = (r, i, l, { allOwnKeys: f } = {}) => (G(i, (y, g) => { l && E(y) ? r[g] = t(y, l) : r[g] = y; }, { allOwnKeys: f }), r), Ve = (r) => (r.charCodeAt(0) === 65279 && (r = r.slice(1)), r), lt = (r, i, l, f) => { r.prototype = Object.create(i.prototype, f), r.prototype.constructor = r, Object.defineProperty(r, "super", { value: i.prototype }), l && Object.assign(r.prototype, l); }, Fe = (r, i, l, f) => { let y, g, w; const S = {}; if (i = i || {}, r == null) return i; do { for (y = Object.getOwnPropertyNames(r), g = y.length; g-- > 0; ) w = y[g], (!f || f(w, r, i)) && !S[w] && (i[w] = r[w], S[w] = !0); r = l !== !1 && n(r); } while (r && (!l || l(r, i)) && r !== Object.prototype); return i; }, se = (r, i, l) => { r = String(r), (l === void 0 || l > r.length) && (l = r.length), l -= i.length; const f = r.indexOf(i, l); return f !== -1 && f === l; }, Me = (r) => { if (!r) return null; if (o(r)) return r; let i = r.length; if (!p(i)) return null; const l = new Array(i); for (; i-- > 0; ) l[i] = r[i]; return l; }, $e = /* @__PURE__ */ ((r) => (i) => r && i instanceof r)(typeof Uint8Array < "u" && n(Uint8Array)), Ge = (r, i) => { const f = (r && r[Symbol.iterator]).call(r); let y; for (; (y = f.next()) && !y.done; ) { const g = y.value; i.call(r, g[0], g[1]); } }, tt = (r, i) => { let l; const f = []; for (; (l = r.exec(i)) !== null; ) f.push(l); return f; }, Et = a("HTMLFormElement"), en = (r) => r.toLowerCase().replace( /[-_\s]([a-z\d])(\w*)/g, function(l, f, y) { return f.toUpperCase() + y; } ), St = (({ hasOwnProperty: r }) => (i, l) => r.call(i, l))(Object.prototype), Xe = a("RegExp"), ft = (r, i) => { const l = Object.getOwnPropertyDescriptors(r), f = {}; G(l, (y, g) => { let w; (w = i(y, g, r)) !== !1 && (f[g] = w || y); }), Object.defineProperties(r, f); }, Xn = (r) => { ft(r, (i, l) => { if (E(r) && ["arguments", "caller", "callee"].indexOf(l) !== -1) return !1; const f = r[l]; if (E(f)) { if (i.enumerable = !1, "writable" in i) { i.writable = !1; return; } i.set || (i.set = () => { throw Error("Can not rewrite read-only method '" + l + "'"); }); } }); }, $ = (r, i) => { const l = {}, f = (y) => { y.forEach((g) => { l[g] = !0; }); }; return o(r) ? f(r) : f(String(r).split(i)), l; }, j = () => { }, fe = (r, i) => r != null && Number.isFinite(r = +r) ? r : i; function K(r) { return !!(r && E(r.append) && r[Symbol.toStringTag] === "FormData" && r[Symbol.iterator]); } const _e = (r) => { const i = new Array(10), l = (f, y) => { if (v(f)) { if (i.indexOf(f) >= 0) return; if (!("toJSON" in f)) { i[y] = f; const g = o(f) ? [] : {}; return G(f, (w, S) => { const A = l(w, y + 1); !d(A) && (g[S] = A); }), i[y] = void 0, g; } } return f; }; return l(r, 0); }, He = a("AsyncFunction"), re = (r) => r && (v(r) || E(r)) && E(r.then) && E(r.catch), he = ((r, i) => r ? setImmediate : i ? ((l, f) => (le.addEventListener("message", ({ source: y, data: g }) => { y === le && g === l && f.length && f.shift()(); }, !1), (y) => { f.push(y), le.postMessage(l, "*"); }))(`axios@${Math.random()}`, []) : (l) => setTimeout(l))( typeof setImmediate == "function", E(le.postMessage) ), Se = typeof queueMicrotask < "u" ? queueMicrotask.bind(le) : typeof process < "u" && process.nextTick || he; var _ = { isArray: o, isArrayBuffer: u, isBuffer: h, isFormData: J, isArrayBufferView: m, isString: b, isNumber: p, isBoolean: R, isObject: v, isPlainObject: q, isReadableStream: N, isRequest: pe, isResponse: M, isHeaders: ce, isUndefined: d, isDate: x, isFile: X, isBlob: z, isRegExp: Xe, isFunction: E, isStream: U, isURLSearchParams: ke, isTypedArray: $e, isFileList: H, forEach: G, merge: Y, extend: ge, trim: be, stripBOM: Ve, inherits: lt, toFlatObject: Fe, kindOf: s, kindOfTest: a, endsWith: se, toArray: Me, forEachEntry: Ge, matchAll: tt, isHTMLForm: Et, hasOwnProperty: St, hasOwnProp: St, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: ft, freezeMethods: Xn, toObjectSet: $, toCamelCase: en, noop: j, toFiniteNumber: fe, findKey: ue, global: le, isContextDefined: Ne, isSpecCompliantForm: K, toJSONObject: _e, isAsyncFn: He, isThenable: re, setImmediate: he, asap: Se }; function k(r, i, l, f, y) { Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = r, this.name = "AxiosError", i && (this.code = i), l && (this.config = l), f && (this.request = f), y && (this.response = y, this.status = y.status ? y.status : null); } _.inherits(k, Error, { toJSON: function() { 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: _.toJSONObject(this.config), code: this.code, status: this.status }; } }); const ht = k.prototype, ye = {}; [ "ERR_BAD_OPTION_VALUE", "ERR_BAD_OPTION", "ECONNABORTED", "ETIMEDOUT", "ERR_NETWORK", "ERR_FR_TOO_MANY_REDIRECTS", "ERR_DEPRECATED", "ERR_BAD_RESPONSE", "ERR_BAD_REQUEST", "ERR_CANCELED", "ERR_NOT_SUPPORT", "ERR_INVALID_URL" // eslint-disable-next-line func-names ].forEach((r) => { ye[r] = { value: r }; }), Object.defineProperties(k, ye), Object.defineProperty(ht, "isAxiosError", { value: !0 }), k.from = (r, i, l, f, y, g) => { const w = Object.create(ht); return _.toFlatObject(r, w, function(A) { return A !== Error.prototype; }, (S) => S !== "isAxiosError"), k.call(w, r.message, i, l, f, y), w.cause = r, w.name = r.name, g && Object.assign(w, g), w; }; var Re = null; function Ye(r) { return _.isPlainObject(r) || _.isArray(r); } function Rt(r) { return _.endsWith(r, "[]") ? r.slice(0, -2) : r; } function nt(r, i, l) { return r ? r.concat(i).map(function(y, g) { return y = Rt(y), !l && g ? "[" + y + "]" : y; }).join(l ? "." : "") : i; } function Cr(r) { return _.isArray(r) && !r.some(Ye); } const Lr = _.toFlatObject(_, {}, null, function(i) { return /^is[A-Z]/.test(i); }); function Tt(r, i, l) { if (!_.isObject(r)) throw new TypeError("target must be an object"); i = i || new FormData(), l = _.toFlatObject(l, { metaTokens: !0, dots: !1, indexes: !1 }, !1, function(F, D) { return !_.isUndefined(D[F]); }); const f = l.metaTokens, y = l.visitor || O, g = l.dots, w = l.indexes, A = (l.Blob || typeof Blob < "u" && Blob) && _.isSpecCompliantForm(i); if (!_.isFunction(y)) throw new TypeError("visitor must be a function"); function T(L) { if (L === null) return ""; if (_.isDate(L)) return L.toISOString(); if (!A && _.isBlob(L)) throw new k("Blob is not supported. Use a Buffer instead."); return _.isArrayBuffer(L) || _.isTypedArray(L) ? A && typeof Blob == "function" ? new Blob([L]) : Buffer.from(L) : L; } function O(L, F, D) { let Q = L; if (L && !D && typeof L == "object") { if (_.endsWith(F, "{}")) F = f ? F : F.slice(0, -2), L = JSON.stringify(L); else if (_.isArray(L) && Cr(L) || (_.isFileList(L) || _.endsWith(F, "[]")) && (Q = _.toArray(L))) return F = Rt(F), Q.forEach(function(de, qe) { !(_.isUndefined(de) || de === null) && i.append( // eslint-disable-next-line no-nested-ternary w === !0 ? nt([F], qe, g) : w === null ? F : F + "[]", T(de) ); }), !1; } return Ye(L) ? !0 : (i.append(nt(D, F, g), T(L)), !1); } const C = [], W = Object.assign(Lr, { defaultVisitor: O, convertValue: T, isVisitable: Ye }); function ie(L, F) { if (!_.isUndefined(L)) { if (C.indexOf(L) !== -1) throw Error("Circular reference detected in " + F.join(".")); C.push(L), _.forEach(L, function(Q, oe) { (!(_.isUndefined(Q) || Q === null) && y.call( i, Q, _.isString(oe) ? oe.trim() : oe, F, W )) === !0 && ie(Q, F ? F.concat(oe) : [oe]); }), C.pop(); } } if (!_.isObject(r)) throw new TypeError("data must be an object"); return ie(r), i; } function Yn(r) { const i = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+", "%00": "\0" }; return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g, function(f) { return i[f]; }); } function tn(r, i) { this._pairs = [], r && Tt(r, this, i); } const Qn = tn.prototype; Qn.append = function(i, l) { this._pairs.push([i, l]); }, Qn.toString = function(i) { const l = i ? function(f) { return i.call(this, f, Yn); } : Yn; return this._pairs.map(function(y) { return l(y[0]) + "=" + l(y[1]); }, "").join("&"); }; function Dr(r) { return encodeURIComponent(r).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); } function Zn(r, i, l) { if (!i) return r; const f = l && l.encode || Dr; _.isFunction(l) && (l = { serialize: l }); const y = l && l.serialize; let g; if (y ? g = y(i, l) : g = _.isURLSearchParams(i) ? i.toString() : new tn(i, l).toString(f), g) { const w = r.indexOf("#"); w !== -1 && (r = r.slice(0, w)), r += (r.indexOf("?") === -1 ? "?" : "&") + g; } return r; } class kr { 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` * * @return {Number} An ID used to remove interceptor later */ use(i, l, f) { return this.handlers.push({ fulfilled: i, rejected: l, synchronous: f ? f.synchronous : !1, runWhen: f ? f.runWhen : null }), this.handlers.length - 1; } /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` * * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise */ 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) { _.forEach(this.handlers, function(f) { f !== null && i(f); }); } } var es = kr, ts = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1 }, Nr = typeof URLSearchParams < "u" ? URLSearchParams : tn, Fr = typeof FormData < "u" ? FormData : null, Br = typeof Blob < "u" ? Blob : null, Pr = { isBrowser: !0, classes: { URLSearchParams: Nr, FormData: Fr, Blob: Br }, protocols: ["http", "https", "file", "blob", "url", "data"] }; const nn = typeof window < "u" && typeof document < "u", sn = typeof navigator == "object" && navigator || void 0, Ur = nn && (!sn || ["ReactNative", "NativeScript", "NS"].indexOf(sn.product) < 0), qr = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Ir = nn && window.location.href || "http://localhost"; var jr = /* @__PURE__ */ Object.freeze({ __proto__: null, hasBrowserEnv: nn, hasStandardBrowserWebWorkerEnv: qr, hasStandardBrowserEnv: Ur, navigator: sn, origin: Ir }), me = { ...jr, ...Pr }; function Vr(r, i) { return Tt(r, new me.classes.URLSearchParams(), Object.assign({ visitor: function(l, f, y, g) { return me.isNode && _.isBuffer(l) ? (this.append(f, l.toString("base64")), !1) : g.defaultVisitor.apply(this, arguments); } }, i)); } function Mr(r) { return _.matchAll(/\w+|\[(\w*)]/g, r).map((i) => i[0] === "[]" ? "" : i[1] || i[0]); } function $r(r) { const i = {}, l = Object.keys(r); let f; const y = l.length; let g; for (f = 0; f < y; f++) g = l[f], i[g] = r[g]; return i; } function ns(r) { function i(l, f, y, g) { let w = l[g++]; if (w === "__proto__") return !0; const S = Number.isFinite(+w), A = g >= l.length; return w = !w && _.isArray(y) ? y.length : w, A ? (_.hasOwnProp(y, w) ? y[w] = [y[w], f] : y[w] = f, !S) : ((!y[w] || !_.isObject(y[w])) && (y[w] = []), i(l, f, y[w], g) && _.isArray(y[w]) && (y[w] = $r(y[w])), !S); } if (_.isFormData(r) && _.isFunction(r.entries)) { const l = {}; return _.forEachEntry(r, (f, y) => { i(Mr(f), y, l, 0); }), l; } return null; } function Hr(r, i, l) { if (_.isString(r)) try { return (i || JSON.parse)(r), _.trim(r); } catch (f) { if (f.name !== "SyntaxError") throw f; } return (l || JSON.stringify)(r); } const rn = { transitional: ts, adapter: ["xhr", "http", "fetch"], transformRequest: [function(i, l) { const f = l.getContentType() || "", y = f.indexOf("application/json") > -1, g = _.isObject(i); if (g && _.isHTMLForm(i) && (i = new FormData(i)), _.isFormData(i)) return y ? JSON.stringify(ns(i)) : i; if (_.isArrayBuffer(i) || _.isBuffer(i) || _.isStream(i) || _.isFile(i) || _.isBlob(i) || _.isReadableStream(i)) return i; if (_.isArrayBufferView(i)) return i.buffer; if (_.isURLSearchParams(i)) return l.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), i.toString(); let S; if (g) { if (f.indexOf("application/x-www-form-urlencoded") > -1) return Vr(i, this.formSerializer).toString(); if ((S = _.isFileList(i)) || f.indexOf("multipart/form-data") > -1) { const A = this.env && this.env.FormData; return Tt( S ? { "files[]": i } : i, A && new A(), this.formSerializer ); } } return g || y ? (l.setContentType("application/json", !1), Hr(i)) : i; }], transformResponse: [function(i) { const l = this.transitional || rn.transitional, f = l && l.forcedJSONParsing, y = this.responseType === "json"; if (_.isResponse(i) || _.isReadableStream(i)) return i; if (i && _.isString(i) && (f && !this.responseType || y)) { const w = !(l && l.silentJSONParsing) && y; try { return JSON.parse(i); } catch (S) { if (w) throw S.name === "SyntaxError" ? k.from(S, k.ERR_BAD_RESPONSE, this, null, this.response) : S; } } return i; }], /** * A timeout in milliseconds to abort a request. If set to 0 (default) a * timeout is not created. */ timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", maxContentLength: -1, maxBodyLength: -1, env: { FormData: me.classes.FormData, Blob: me.classes.Blob }, validateStatus: function(i) { return i >= 200 && i < 300; }, headers: { common: { Accept: "application/json, text/plain, */*", "Content-Type": void 0 } } }; _.forEach(["delete", "get", "head", "post", "put", "patch"], (r) => { rn.headers[r] = {}; }); var on = rn; const Wr = _.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 zr = (r) => { const i = {}; let l, f, y; return r && r.split(` `).forEach(function(w) { y = w.indexOf(":"), l = w.substring(0, y).trim().toLowerCase(), f = w.substring(y + 1).trim(), !(!l || i[l] && Wr[l]) && (l === "set-cookie" ? i[l] ? i[l].push(f) : i[l] = [f] : i[l] = i[l] ? i[l] + ", " + f : f); }), i; }; const ss = Symbol("internals"); function dt(r) { return r && String(r).trim().toLowerCase(); } function Ot(r) { return r === !1 || r == null ? r : _.isArray(r) ? r.map(Ot) : String(r); } function Jr(r) { const i = /* @__PURE__ */ Object.create(null), l = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let f; for (; f = l.exec(r); ) i[f[1]] = f[2]; return i; } const Kr = (r) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim()); function an(r, i, l, f, y) { if (_.isFunction(f)) return f.call(this, i, l); if (y && (i = l), !!_.isString(i)) { if (_.isString(f)) return i.indexOf(f) !== -1; if (_.isRegExp(f)) return f.test(i); } } function Gr(r) { return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (i, l, f) => l.toUpperCase() + f); } function Xr(r, i) { const l = _.toCamelCase(" " + i); ["get", "set", "has"].forEach((f) => { Object.defineProperty(r, f + l, { value: function(y, g, w) { return this[f].call(this, i, y, g, w); }, configurable: !0 }); }); } class xt { constructor(i) { i && this.set(i); } set(i, l, f) { const y = this; function g(S, A, T) { const O = dt(A); if (!O) throw new Error("header name must be a non-empty string"); const C = _.findKey(y, O); (!C || y[C] === void 0 || T === !0 || T === void 0 && y[C] !== !1) && (y[C || A] = Ot(S)); } const w = (S, A) => _.forEach(S, (T, O) => g(T, O, A)); if (_.isPlainObject(i) || i instanceof this.constructor) w(i, l); else if (_.isString(i) && (i = i.trim()) && !Kr(i)) w(zr(i), l); else if (_.isHeaders(i)) for (const [S, A] of i.entries()) g(A, S, f); else i != null && g(l, i, f); return this; } get(i, l) { if (i = dt(i), i) { const f = _.findKey(this, i); if (f) { const y = this[f]; if (!l) return y; if (l === !0) return Jr(y); if (_.isFunction(l)) return l.call(this, y, f); if (_.isRegExp(l)) return l.exec(y); throw new TypeError("parser must be boolean|regexp|function"); } } } has(i, l) { if (i = dt(i), i) { const f = _.findKey(this, i); return !!(f && this[f] !== void 0 && (!l || an(this, this[f], f, l))); } return !1; } delete(i, l) { const f = this; let y = !1; function g(w) { if (w = dt(w), w) { const S = _.findKey(f, w); S && (!l || an(f, f[S], S, l)) && (delete f[S], y = !0); } } return _.isArray(i) ? i.forEach(g) : g(i), y; } clear(i) { const l = Object.keys(this); let f = l.length, y = !1; for (; f--; ) { const g = l[f]; (!i || an(this, this[g], g, i, !0)) && (delete this[g], y = !0); } return y; } normalize(i) { const l = this, f = {}; return _.forEach(this, (y, g) => { const w = _.findKey(f, g); if (w) { l[w] = Ot(y), delete l[g]; return; } const S = i ? Gr(g) : String(g).trim(); S !== g && delete l[g], l[S] = Ot(y), f[S] = !0; }), this; } concat(...i) { return this.constructor.concat(this, ...i); } toJSON(i) { const l = /* @__PURE__ */ Object.create(null); return _.forEach(this, (f, y) => { f != null && f !== !1 && (l[y] = i && _.isArray(f) ? f.join(", ") : f); }), l; } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator](); } toString() { return Object.entries(this.toJSON()).map(([i, l]) => i + ": " + l).join(` `); } get [Symbol.toStringTag]() { return "AxiosHeaders"; } static from(i) { return i instanceof this ? i : new this(i); } static concat(i, ...l) { const f = new this(i); return l.forEach((y) => f.set(y)), f; } static accessor(i) { const f = (this[ss] = this[ss] = { accessors: {} }).accessors, y = this.prototype; function g(w) { const S = dt(w); f[S] || (Xr(y, w), f[S] = !0); } return _.isArray(i) ? i.forEach(g) : g(i), this; } } xt.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]), _.reduceDescriptors(xt.prototype, ({ value: r }, i) => { let l = i[0].toUpperCase() + i.slice(1); return { get: () => r, set(f) { this[l] = f; } }; }), _.freezeMethods(xt); var Te = xt; function cn(r, i) { const l = this || on, f = i || l, y = Te.from(f.headers); let g = f.data; return _.forEach(r, function(S) { g = S.call(l, g, y.normalize(), i ? i.status : void 0); }), y.normalize(), g; } function rs(r) { return !!(r && r.__CANCEL__); } function st(r, i, l) { k.call(this, r ?? "canceled", k.ERR_CANCELED, i, l), this.name = "CanceledError"; } _.inherits(st, k, { __CANCEL__: !0 }); function is(r, i, l) { const f = l.config.validateStatus; !l.status || !f || f(l.status) ? r(l) : i(new k( "Request failed with status code " + l.status, [k.ERR_BAD_REQUEST, k.ERR_BAD_RESPONSE][Math.floor(l.status / 100) - 4], l.config, l.request, l )); } function Yr(r) { const i = /^([-+\w]{1,25})(:?\/\/|:)/.exec(r); return i && i[1] || ""; } function Qr(r, i) { r = r || 10; const l = new Array(r), f = new Array(r); let y = 0, g = 0, w; return i = i !== void 0 ? i : 1e3, function(A) { const T = Date.now(), O = f[g]; w || (w = T), l[y] = A, f[y] = T; let C = g, W = 0; for (; C !== y; ) W += l[C++], C = C % r; if (y = (y + 1) % r, y === g && (g = (g + 1) % r), T - w < i) return; const ie = O && T - O; return ie ? Math.round(W * 1e3 / ie) : void 0; }; } function Zr(r, i) { let l = 0, f = 1e3 / i, y, g; const w = (T, O = Date.now()) => { l = O, y = null, g && (clearTimeout(g), g = null), r.apply(null, T); }; return [(...T) => { const O = Date.now(), C = O - l; C >= f ? w(T, O) : (y = T, g || (g = setTimeout(() => { g = null, w(y); }, f - C))); }, () => y && w(y)]; } const At = (r, i, l = 3) => { let f = 0; const y = Qr(50, 250); return Zr((g) => { const w = g.loaded, S = g.lengthComputable ? g.total : void 0, A = w - f, T = y(A), O = w <= S; f = w; const C = { loaded: w, total: S, progress: S ? w / S : void 0, bytes: A, rate: T || void 0, estimated: T && S && O ? (S - w) / T : void 0, event: g, lengthComputable: S != null, [i ? "download" : "upload"]: !0 }; r(C); }, l); }, os = (r, i) => { const l = r != null; return [(f) => i[0]({ lengthComputable: l, total: r, loaded: f }), i[1]]; }, as = (r) => (...i) => _.asap(() => r(...i)); var ei = me.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, i) => (l) => (l = new URL(l, me.origin), r.protocol === l.protocol && r.host === l.host && (i || r.port === l.port)))( new URL(me.origin), me.navigator && /(msie|trident)/i.test(me.navigator.userAgent) ) : () => !0, ti = me.hasStandardBrowserEnv ? ( // Standard browser envs support document.cookie { write(r, i, l, f, y, g) { const w = [r + "=" + encodeURIComponent(i)]; _.isNumber(l) && w.push("expires=" + new Date(l).toGMTString()), _.isString(f) && w.push("path=" + f), _.isString(y) && w.push("domain=" + y), g === !0 && w.push("secure"), document.cookie = w.join("; "); }, read(r) { const i = document.cookie.match(new RegExp("(^|;\\s*)(" + r + ")=([^;]*)")); return i ? decodeURIComponent(i[3]) : null; }, remove(r) { this.write(r, "", Date.now() - 864e5); } } ) : ( // Non-standard browser env (web workers, react-native) lack needed support. { write() { }, read() { return null; },