var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/saasRole/serve.ts
var serve_exports = {};
__export(serve_exports, {
  createRole: () => createRole,
  deleteRole: () => deleteRole,
  getAllMembers: () => getAllMembers,
  getExtensionFormList: () => getExtensionFormList,
  getRoleDetail: () => getRoleDetail,
  getRoleMembers: () => getRoleMembers,
  getRolePermission: () => getRolePermission,
  getRoles: () => getRoles,
  removeRoleMember: () => removeRoleMember,
  updateRole: () => updateRole,
  updateRoleMembers: () => updateRoleMembers
});
module.exports = __toCommonJS(serve_exports);
var import_utils = require("../../utils");
var getExtensionFormList = async (params) => {
  const response = await import_utils.request.getRequest().get("/shop/form", params, { isShopApi: true });
  return response.data || { list: [], count: 0 };
};
var getRoles = async () => {
  const response = await import_utils.request.getRequest().get("/tenant/role", {
    "with_count[]": "tenant_account"
  });
  return response.data || [];
};
var getRoleDetail = async (id) => {
  const response = await import_utils.request.getRequest().get(`/tenant/role/${id}`, {});
  return response.data;
};
var createRole = async (role) => {
  const response = await import_utils.request.getRequest().post("/tenant/role", role);
  return response.data;
};
var updateRole = async (id, updates) => {
  const response = await import_utils.request.getRequest().put(`/tenant/role/${id}`, updates);
  return response.data;
};
var deleteRole = async (id) => {
  await import_utils.request.getRequest().remove(`/tenant/role/${id}`);
};
var getRoleMembers = async (params) => {
  const response = await import_utils.request.getRequest().get("/tenant/account", params);
  return response.data || { list: [], count: 0 };
};
var getRolePermission = async () => {
  const response = await import_utils.request.getRequest().get(`/tenant/role/permissions`, {});
  return response.data || {};
};
var updateRoleMembers = async (roleId, accountIds) => {
  await import_utils.request.getRequest().post(`/tenant/role/${roleId}/accounts`, {
    tenant_account_ids: accountIds
  });
};
var removeRoleMember = async (roleId, tenantAccountId) => {
  await import_utils.request.getRequest().remove(
    `/tenant/role/${roleId}/account/${tenantAccountId}`,
    {}
  );
};
var getAllMembers = async (params = {}) => {
  const response = await import_utils.request.getRequest().get("/tenant/account", {
    "with[]": ["roles"],
    ...params
  });
  return response.data;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createRole,
  deleteRole,
  getAllMembers,
  getExtensionFormList,
  getRoleDetail,
  getRoleMembers,
  getRolePermission,
  getRoles,
  removeRoleMember,
  updateRole,
  updateRoleMembers
});
