import { merge as p, cloneDeep as l } from "lodash-es"; import { b as m, u as b } from "./index-50ffe046.mjs"; import * as d from "qiniu-js"; import "vue"; import "@fast-crud/fast-crud"; async function f(n, o, a, e) { const t = await e.getToken({ fileName: o, key: a, file: n, ...e.custom, ...e }); let r = null; return typeof t == "string" ? r = { token: t, expires: 3600 } : r = t, r.expiresTime = (/* @__PURE__ */ new Date()).getTime() + r.expires * 1e3, r.token; } async function g({ file: n, fileName: o, onProgress: a, options: e }) { const t = await m(n, o, e), r = await f(n, o, t, e); return new Promise((u, c) => { d.upload(n, t, r, e.putExtra, e.putConfig).subscribe({ next(s) { s && a(s.total); }, error(s) { c(s); }, async complete(s) { let i = { url: e.domain + "/" + t, key: t }; if (e.successHandle) { i = await e.successHandle(i), u(i); return; } u(i); } }); }); } async function q(n) { const { getConfig: o } = b(), a = o("qiniu"), e = n.options, t = p(l(a), e); return n.options = t, await g(n); } export { f as getToken, q as upload }; //# sourceMappingURL=uploader-qiniu-7f53ab0b.mjs.map