var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
import { l as lodash, aV as walkTemplet, aW as axios } from "./index.js";
import "vue";
function getTempletFonts(content) {
  let names = {
    "SourceHanSansSC-Regular": true
  };
  content = lodash.exports.isString(content) ? JSON.parse(content) : content;
  walkTemplet((element) => {
    const { contents, fontFamily } = element;
    if (fontFamily) {
      names[fontFamily] = true;
      contents && contents.forEach((item) => {
        item.fontFamily && (names[item.fontFamily] = true);
      });
    }
  }, true, content.layouts);
  names = Object.keys(names);
  return names;
}
const apis = {
  queryComposition(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/dam/editors/${data.user_templet_id}/task`, __spreadValues({ params: data }, config));
  },
  createComposition(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/dam/editors/${data.user_templet_id}/task`, data, config);
  },
  getMaterial(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/v2/materials/${data.id}/info`, __spreadValues({
      params: data
    }, config));
  },
  getDamMaterial(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/dam/editors/materials/${data.id}/info`, __spreadValues({ params: data }, config));
  },
  getUserTemplate(data, config = {}) {
    return apiService.apis.getDamMaterial(data, config);
  },
  createUserTemplate(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/dam/editors/materials/info`, data, config);
  },
  updateUserTemplate(data, config = {}) {
    return apiService.axios.put(`${apiService.baseUrl}/api/dam/editors/materials/${data.id}/info`, data, config);
  },
  getRiskMaterials(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/user_templets/${data.id}/risk_materials`, __spreadValues({ params: data }, config));
  },
  postUserRights(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/user_templets/${data.id}/user-rights/use`, data, config);
  },
  getUserRightCount(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/user_templets/${data.id}/user-rights/count`, data, config);
  },
  getUserRights(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/user_templets/${data.id}/user-rights/check`, data, config);
  },
  updateUserRightsCount(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/user_templets/${data.id}/user-rights/use`, data, config);
  },
  postShot(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/shots`, data, config);
  },
  getShot(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/shots/${data.id}`, __spreadValues({
      params: data
    }, config));
  },
  postShotV2(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/open/editor/media-render`, data, config);
  },
  getShotV2(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/open/editor/media-render`, __spreadValues({
      params: data
    }, config));
  },
  getDamFonts(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/dam/fonts/match`, __spreadValues({
      params: data
    }, config));
  },
  getFontSubset(data, config = {}) {
    return apiService.axios.get(`${apiService.fonterBaseUrl}/subset`, __spreadValues({
      responseType: "blob",
      params: __spreadValues({}, data)
    }, config));
  },
  async getFontsByTemplet(templet) {
    const names = await getTempletFonts(templet.content);
    const { data } = await apiService.axios.get(`${apiService.baseUrl}/api/dam/fonts/match`, {
      params: {
        names: names.toString(),
        page_size: names.length
      }
    });
    data.forEach((item) => {
      Object.assign(item, item.content);
    });
    return data;
  },
  postEmsLogs(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/ems/logs`, data, config);
  },
  getSubscriptConfig(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/v3/bp/osms/delivery-pits/${data.position}/modules`, __spreadValues({ params: data }, config));
  },
  filemsUpload() {
    throw new Error("filemsUpload \u5FC5\u987B\u8BBE\u7F6E");
  },
  captureException() {
  },
  loadCustomSizeList() {
    return apiService.axios.get(`${apiService.baseUrl}/api/open/editor/custom-size`);
  },
  postCustomSize(data) {
    return apiService.axios.post(`${apiService.baseUrl}/api/open/editor/custom-size`, data);
  },
  deleteCustomSize(id) {
    return apiService.axios.delete(`${apiService.baseUrl}/api/open/editor/custom-size/${id}`);
  },
  loadPreCustomSizeList() {
    return apiService.axios.get(`${apiService.baseUrl}/api/open/editor/config/pre-install`);
  }
};
const saasApis = {
  queryComposition(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cm/editors/${data.user_templet_id}/task`, __spreadValues({ params: data }, config));
  },
  createComposition(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/cm/editors/${data.user_templet_id}/task`, data, config);
  },
  getDamMaterial(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cm/editors/materials/${data.id}/info`, __spreadValues({ params: data }, config));
  },
  createUserTemplate(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/cm/editors/materials/info`, data, config);
  },
  updateUserTemplate(data, config = {}) {
    return apiService.axios.put(`${apiService.baseUrl}/api/cm/editors/materials/${data.id}/info`, data, config);
  },
  getDamFonts(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cm/fonts/match`, __spreadValues({
      params: data
    }, config));
  },
  getMaterial(data, config) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cdm/editors/materials/${data.id}/info`, __spreadValues({ params: data }, config));
  },
  getRiskMaterials(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cm/editors/risk_materials`, __spreadValues({
      params: data
    }, config));
  },
  postShot(data, config = {}) {
    return apiService.axios.post(`${apiService.baseUrl}/api/cm/editors/shots`, data, config);
  },
  getShot(data, config = {}) {
    return apiService.axios.get(`${apiService.baseUrl}/api/cm/editors/shots/${data.id}`, __spreadValues({
      params: data
    }, config));
  },
  getFontSubset: (data, config = {}) => {
    return apiService.axios.get(`${apiService.fonterBaseUrl}/subset`, __spreadValues({
      responseType: "blob",
      params: __spreadValues({
        from: apiService.from,
        env: apiService.env,
        org_code: apiService.orgCode
      }, data)
    }, config));
  },
  async getFontsByTemplet(templet) {
    const names = await getTempletFonts(templet.content);
    const { data } = await apiService.axios.get(`${apiService.baseUrl}/api/cm/fonts/match`, {
      params: {
        names: names.toString(),
        page_size: names.length
      }
    });
    data.forEach((item) => {
      Object.assign(item, item.content);
    });
    return data;
  }
};
const apiService = {
  env: "",
  from: "",
  orgCode: "",
  axios,
  baseUrl: window.origin,
  fonterBaseUrl: "https://fonter.dancf.com",
  apis
};
function initApiService(config) {
  if (config.from === "saas" || config.from === "ka") {
    lodash.exports.merge(apiService, { apis: saasApis }, config);
  } else {
    lodash.exports.merge(apiService, config);
  }
  window.axios = config.axios;
}
export { apiService as default, initApiService };
