"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const useAppState = require("../../../../lib/useAppState.js");
const toast = require("react-hot-toast");
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const toast__default = /* @__PURE__ */ _interopDefaultLegacy(toast);
const deleteMedia = (url) => {
  console.log("deleteMedia-->", url);
  const key = url.replace(/^https:\/\/[^/]+/, "");
  console.log("deleteMedia-->", key);
  cos.deleteObject({
    Bucket: useAppState.cosConfig.Bucket,
    Region: useAppState.cosConfig.Region,
    Key: key
  }, (err, data) => {
    if (err && err.error)
      ;
    else if (err)
      ;
    else {
      toast__default.default.success("\u5DF2\u6210\u529F\u5220\u9664");
    }
  });
};
const getAuthorization = function(options, callback) {
  const authorization = COS.getAuthorization({
    SecretId: useAppState.cosConfig.SecretId,
    SecretKey: useAppState.cosConfig.SecretKey,
    Method: options.Method,
    Pathname: options.Pathname,
    Query: options.Query,
    Headers: options.Headers,
    Expires: 60
  });
  callback({
    Authorization: authorization
  });
};
let COS;
if (typeof window !== "undefined" || typeof document !== "undefined") {
  COS = require("cos-js-sdk-v5");
}
const cos = typeof window !== "undefined" ? new COS({
  getAuthorization
}) : {};
exports.cos = cos;
exports.deleteMedia = deleteMedia;
//# sourceMappingURL=sdk.js.map
