import type { ApiContext, PaginatedResult } from './_shared';
import type { ApplicationAccessLevel, BulkAssignAppsRequest, BulkAssignAppsResponse } from './applications';
import type { UserTenantDto } from './crossCutting';
export type TenantStatus = 'Pending' | 'Active' | 'Suspended' | 'Archived';
export type TenantType = 'Personal' | 'Business' | 'System';
export interface TenantListDto {
    id: string;
    name: string;
    slug: string;
    type: TenantType;
    status: TenantStatus;
    description: string | null;
    organisationId: string | null;
    organisation: {
        id: string;
        name: string;
    } | null;
    templateId: string | null;
    templateName: string | null;
    templateCode: string | null;
    memberCount: number;
    applicationCount: number;
    pendingAccessRequestCount: number;
    createdAt: string;
}
export interface TenantOrganisationDto {
    id: string;
    name: string;
    legalName: string | null;
    countryCode: string;
    businessIdentifier: string;
    businessIdentifierType: string;
    vatNumber: string | null;
    address: {
        street: string;
        street2: string | null;
        postalCode: string;
        city: string;
        state: string | null;
        country: string;
        countryCode: string;
    };
    phone: string | null;
    email: string | null;
    website: string | null;
    verificationStatus: string;
    verifiedAt: string | null;
    verificationNotes: string | null;
}
export interface TenantDetailDto {
    id: string;
    name: string;
    slug: string;
    type: TenantType;
    status: TenantStatus;
    description: string | null;
    organisationId: string | null;
    organisation: TenantOrganisationDto | null;
    templateId: string | null;
    templateName: string | null;
    templateCode: string | null;
    createdAt: string;
    createdBy: string | null;
    updatedAt: string | null;
    updatedBy: string | null;
    activatedAt: string | null;
    suspendedAt: string | null;
    archivedAt: string | null;
    memberCount: number;
    applicationCount: number;
    pendingAccessRequestCount: number;
}
export interface TenantMemberDto {
    /** User ID - use this as memberId for API calls (backend: "memberId is actually the userId") */
    userId: string;
    userEmail: string | null;
    userDisplayName: string | null;
    isOwner: boolean;
    joinedAt: string;
    roles: TenantMemberRoleDto[];
    /** How the user has access to this tenant: Direct, Group, or Both */
    membershipSource: 'Direct' | 'Group' | 'Both';
    /** The primary group granting access (if via group) */
    primaryGroupId: string | null;
    /** The name of the primary group granting access (if via group) */
    primaryGroupName: string | null;
}
export interface TenantMemberRoleDto {
    roleId: string;
    roleName: string;
    assignedAt: string;
    assignedBy: string | null;
}
export interface TenantMemberCustomRoleDto {
    id: string;
    name: string;
    shortName: string;
    code: string | null;
    category: string;
    description: string | null;
    isSystem: boolean;
    permissions: TenantMemberCustomRolePermissionDto[];
    createdAt: string;
    updatedAt: string | null;
}
export interface TenantMemberCustomRolePermissionDto {
    id: string;
    path: string;
    description: string | null;
}
export interface TenantGroupDto {
    groupId: string;
    name: string;
    description: string | null;
    isActive: boolean;
    isSecurityGroup: boolean;
    isSyncedFromEntra: boolean;
    entraObjectId: string | null;
    memberCount: number;
    roleCount: number;
    isDirect: boolean;
    linkedViaGroupId: string | null;
    linkedViaGroupName: string | null;
    addedAt: string | null;
    addedBy: string | null;
}
export interface AvailableGroupDto {
    groupId: string;
    name: string;
    description: string | null;
    isSecurityGroup: boolean;
    isSyncedFromEntra: boolean;
    memberCount: number;
}
export type TenantApplicationSource = 'Inherited' | 'Direct' | 'Overridden' | 'Revoked';
export interface TenantApplicationDto {
    applicationId: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    accessLevel: ApplicationAccessLevel;
    assignedAt: string;
    assignedBy: string | null;
    source: TenantApplicationSource;
    inheritedModuleCount: number;
    directModuleCount: number;
    revokedModuleCount: number;
    inheritedSectionCount: number;
    directSectionCount: number;
    revokedSectionCount: number;
    totalModuleCount: number;
    totalSectionCount: number;
}
export interface EffectiveModuleNode {
    moduleId: string;
    label: string;
    code: string;
    icon: string | null;
    source: TenantApplicationSource | 'Unavailable';
    accessLevel: string;
    isEffectivelyActive: boolean;
    sections: EffectiveSectionNode[];
}
export interface EffectiveSectionNode {
    sectionId: string;
    label: string;
    code: string;
    icon: string | null;
    source: TenantApplicationSource | 'Unavailable';
    accessLevel: string;
    isEffectivelyActive: boolean;
}
export type OverrideAction = 'add' | 'revoke' | 'remove-override';
export interface ModuleOverrideItem {
    moduleId: string;
    action: OverrideAction;
}
export interface SectionOverrideItem {
    sectionId: string;
    action: OverrideAction;
}
export interface SaveOverridesRequest {
    modules?: ModuleOverrideItem[];
    sections?: SectionOverrideItem[];
}
export interface AvailableApplicationDto {
    id: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    isAssigned: boolean;
}
export interface TenantRoleDto {
    id: string;
    name: string;
    shortName: string;
    code: string | null;
    category: string;
    description: string | null;
    isSystem: boolean;
    applicationId: string | null;
    applicationName: string | null;
    permissionsCount: number;
    assignedMembersCount: number;
}
export interface TenantModuleDto {
    moduleId: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    accessLevel: string;
    assignedAt: string;
    assignedBy: string | null;
}
export interface AvailableModuleDto {
    id: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    applicationLabel: string;
    isAssigned: boolean;
}
export interface TenantSectionDto {
    sectionId: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    accessLevel: string;
    assignedAt: string;
    assignedBy: string | null;
}
export interface AvailableSectionDto {
    id: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    moduleLabel: string;
    isAssigned: boolean;
}
export interface ModuleWithSectionsDto {
    moduleId: string;
    label: string;
    code: string;
    icon: string | null;
    isAssigned: boolean;
    accessLevel: string | null;
    sections: SectionAssignmentDto[];
}
export interface SectionAssignmentDto {
    sectionId: string;
    label: string;
    code: string;
    icon: string | null;
    isAssigned: boolean;
    accessLevel: string | null;
}
export interface CreateTenantB2CRequest {
    name: string;
    slug: string;
    description?: string;
    templateId?: string;
}
export interface TenantTemplateDto {
    id: string;
    code: string;
    name: string;
    description: string | null;
    targetTenantType: TenantType;
    isDefault: boolean;
    isActive: boolean;
    tenantCount: number;
    applicationCount: number;
    createdAt: string;
}
export interface TenantTemplateDetailDto {
    id: string;
    code: string;
    name: string;
    description: string | null;
    targetTenantType: TenantType;
    isDefault: boolean;
    isActive: boolean;
    createdAt: string;
    applications: TemplateApplicationDto[];
    modules: TemplateModuleDto[];
    sections: TemplateSectionDto[];
}
export interface TemplateApplicationDto {
    applicationId: string;
    label: string;
    code: string;
    icon: string | null;
    accessLevel: string;
    displayOrder: number;
}
export interface TemplateModuleDto {
    moduleId: string;
    label: string;
    code: string;
    icon: string | null;
    displayOrder: number;
}
export interface TemplateSectionDto {
    sectionId: string;
    label: string;
    code: string;
    icon: string | null;
    displayOrder: number;
}
export interface CreateTenantTemplateRequest {
    code: string;
    name: string;
    description?: string;
    targetTenantType: TenantType;
}
export interface UpdateTenantTemplateRequest {
    name: string;
    description?: string;
}
export interface BulkAssignTemplateAppsRequest {
    applicationIds: string[];
    accessLevel?: string;
    accessMode?: string;
    moduleIds?: string[];
    sectionIds?: string[];
}
export interface TemplateApplicationEnrichedDto {
    applicationId: string;
    label: string;
    code: string;
    description: string | null;
    icon: string | null;
    accessLevel: string;
    displayOrder: number;
    assignedAt: string;
    assignedBy: string | null;
    assignedModuleCount: number;
    assignedSectionCount: number;
    totalModuleCount: number;
    totalSectionCount: number;
}
export interface TenantBasicDto {
    id: string;
    slug: string;
    name: string;
    createdAt: string;
}
export interface TemplateAppModuleTreeDto {
    moduleId: string;
    label: string;
    code: string;
    icon: string | null;
    isAssigned: boolean;
    sections: TemplateAppSectionTreeDto[];
}
export interface TemplateAppSectionTreeDto {
    sectionId: string;
    label: string;
    code: string;
    icon: string | null;
    isAssigned: boolean;
}
export interface UpdateTemplateAppModulesRequest {
    accessMode: 'full' | 'custom';
    moduleIds?: string[];
    sectionIds?: string[];
}
export interface TemplateAiInstanceDto {
    id: string;
    instanceId: string;
    instanceCode: string;
    instanceName: string;
    isActive: boolean;
    displayOrder: number;
    assignedAt: string;
    assignedBy: string | null;
}
export type BusinessIdentifierType = 'SIREN' | 'SIRET' | 'UID_CHE' | 'HRB' | 'HRA' | 'BCE_KBO' | 'KVK' | 'CIF' | 'PartitaIVA' | 'CRN' | 'VAT' | 'ABN' | 'Other';
export interface CreateAddressRequest {
    street: string;
    street2?: string;
    postalCode: string;
    city: string;
    state?: string;
    country: string;
    countryCode: string;
}
export interface CreateOrganisationRequest {
    name: string;
    legalName?: string;
    countryCode: string;
    businessIdentifierType: BusinessIdentifierType;
    businessIdentifier: string;
    vatNumber?: string;
    address: CreateAddressRequest;
    phone?: string;
    email?: string;
    website?: string;
    isFromRegistry?: boolean;
}
export type VerificationStatus = 'Pending' | 'Verified' | 'Rejected';
export interface OrganisationListItemDto {
    id: string;
    name: string;
    legalName: string | null;
    countryCode: string;
    businessIdentifier: string;
    businessIdentifierType: BusinessIdentifierType;
    verificationStatus: VerificationStatus;
    verifiedAt: string | null;
    createdAt: string;
}
export interface AddressDto {
    street: string;
    street2: string | null;
    postalCode: string;
    city: string;
    state: string | null;
    country: string;
    countryCode: string;
}
export interface OrganisationDto {
    id: string;
    name: string;
    legalName: string | null;
    countryCode: string;
    businessIdentifier: string;
    businessIdentifierType: BusinessIdentifierType;
    vatNumber: string | null;
    address: AddressDto | null;
    phone: string | null;
    email: string | null;
    website: string | null;
    verificationStatus: VerificationStatus;
    verifiedAt: string | null;
    verificationNotes: string | null;
    verifiedBy: string | null;
    createdAt: string;
    createdBy: string | null;
    updatedAt: string | null;
    updatedBy: string | null;
}
export interface CreateTenantB2BRequest {
    name: string;
    slug: string;
    description?: string;
    organisation?: CreateOrganisationRequest;
    organisationId?: string;
}
export interface CompanyLookupResponse {
    identifier: string;
    name: string;
    legalName: string | null;
    legalForm: string | null;
    street: string | null;
    street2: string | null;
    postalCode: string | null;
    city: string | null;
    state: string | null;
    country: string | null;
    countryCode: string | null;
    vatNumber: string | null;
    phone: string | null;
    email: string | null;
    website: string | null;
    status: string | null;
    registryUrl: string | null;
}
export interface UpdateTenantRequest {
    name: string;
    description?: string;
    type?: TenantType;
}
export interface AddTenantMemberRequest {
    userId: string;
    isOwner?: boolean;
}
export interface AssignTenantRoleRequest {
    roleId: string;
}
export interface MultitenantConfigResponse {
    enableB2B: boolean;
    enableB2C: boolean;
}
declare const _createTenantsApi: (apiContext: ApiContext) => {
    getConfig: () => Promise<MultitenantConfigResponse>;
    getAll: (params?: {
        page?: number;
        pageSize?: number;
        search?: string;
        status?: TenantStatus;
        type?: TenantType;
        sortBy?: string;
        sortDesc?: boolean;
        excludeTypes?: TenantType[];
    }) => Promise<PaginatedResult<TenantListDto>>;
    getById: (id: string) => Promise<TenantDetailDto>;
    createB2C: (data: CreateTenantB2CRequest) => Promise<TenantDetailDto>;
    createB2B: (data: CreateTenantB2BRequest) => Promise<TenantDetailDto>;
    update: (id: string, data: UpdateTenantRequest) => Promise<TenantDetailDto>;
    delete: (id: string) => Promise<unknown>;
    activate: (id: string) => Promise<unknown>;
    suspend: (id: string) => Promise<unknown>;
    archive: (id: string) => Promise<unknown>;
    checkSlugAvailable: (slug: string) => Promise<{
        available: boolean;
    }>;
    assignTemplate: (tenantId: string, templateId: string) => Promise<unknown>;
    removeTemplate: (tenantId: string) => Promise<unknown>;
    getMembers: (tenantId: string) => Promise<TenantMemberDto[]>;
    getMember: (tenantId: string, memberId: string) => Promise<TenantMemberDto>;
    addMember: (tenantId: string, data: AddTenantMemberRequest) => Promise<TenantMemberDto>;
    removeMember: (tenantId: string, userId: string) => Promise<unknown>;
    setMemberDefault: (tenantId: string, userId: string) => Promise<unknown>;
    transferOwnership: (tenantId: string, toUserId: string) => Promise<unknown>;
    assignRole: (tenantId: string, tenantUserId: string, roleId: string) => Promise<unknown>;
    removeRole: (tenantId: string, tenantUserId: string, roleId: string) => Promise<unknown>;
    assignMemberRoles: (tenantId: string, tenantUserId: string, roleIds: string[]) => Promise<unknown>;
    getMemberCustomRole: (tenantId: string, memberId: string) => Promise<TenantMemberCustomRoleDto | null>;
    createMemberCustomRole: (tenantId: string, memberId: string) => Promise<TenantMemberCustomRoleDto>;
    deleteMemberCustomRole: (tenantId: string, memberId: string) => Promise<unknown>;
    getTenantRoles: (tenantId: string) => Promise<TenantRoleDto[]>;
    getGroups: (tenantId: string) => Promise<TenantGroupDto[]>;
    getAvailableGroups: (tenantId: string) => Promise<AvailableGroupDto[]>;
    addGroupToTenant: (tenantId: string, groupId: string) => Promise<unknown>;
    removeGroupFromTenant: (tenantId: string, groupId: string) => Promise<unknown>;
    getApplications: (tenantId: string) => Promise<TenantApplicationDto[]>;
    getAvailableApplications: (tenantId: string) => Promise<AvailableApplicationDto[]>;
    assignApplication: (tenantId: string, applicationId: string) => Promise<TenantApplicationDto>;
    removeApplication: (tenantId: string, applicationId: string) => Promise<unknown>;
    bulkAssignApplications: (tenantId: string, request: BulkAssignAppsRequest) => Promise<BulkAssignAppsResponse>;
    toggleApplication: (tenantId: string, applicationId: string, isActive: boolean) => Promise<unknown>;
    updateApplicationAccessLevel: (tenantId: string, applicationId: string, accessLevel: ApplicationAccessLevel) => Promise<unknown>;
    getEffectiveTree: (tenantId: string, applicationId: string) => Promise<EffectiveModuleNode[]>;
    saveOverrides: (tenantId: string, applicationId: string, request: SaveOverridesRequest) => Promise<unknown>;
    getModules: (tenantId: string) => Promise<TenantModuleDto[]>;
    getAvailableModules: (tenantId: string) => Promise<AvailableModuleDto[]>;
    assignModule: (tenantId: string, moduleId: string) => Promise<TenantModuleDto>;
    removeModule: (tenantId: string, moduleId: string) => Promise<unknown>;
    toggleModule: (tenantId: string, moduleId: string, isActive: boolean) => Promise<unknown>;
    getSections: (tenantId: string) => Promise<TenantSectionDto[]>;
    getAvailableSections: (tenantId: string) => Promise<AvailableSectionDto[]>;
    assignSection: (tenantId: string, sectionId: string) => Promise<TenantSectionDto>;
    removeSection: (tenantId: string, sectionId: string) => Promise<unknown>;
    toggleSection: (tenantId: string, sectionId: string, isActive: boolean) => Promise<unknown>;
    getModulesWithSections: (tenantId: string, applicationId: string) => Promise<ModuleWithSectionsDto[]>;
    linkOrganisation: (tenantId: string, organisationId: string) => Promise<unknown>;
    unlinkOrganisation: (tenantId: string) => Promise<unknown>;
};
export type TenantsApi = ReturnType<typeof _createTenantsApi>;
export declare const createTenantsApi: (apiContext: ApiContext) => TenantsApi;
declare const _createTemplatesApi: (apiContext: ApiContext) => {
    getAll: () => Promise<TenantTemplateDto[]>;
    getById: (id: string) => Promise<TenantTemplateDetailDto>;
    create: (data: CreateTenantTemplateRequest) => Promise<TenantTemplateDto>;
    update: (id: string, data: UpdateTenantTemplateRequest) => Promise<TenantTemplateDto>;
    delete: (id: string) => Promise<unknown>;
    assignApplication: (templateId: string, appId: string) => Promise<unknown>;
    removeApplication: (templateId: string, appId: string) => Promise<unknown>;
    bulkAssignApplications: (templateId: string, request: BulkAssignTemplateAppsRequest) => Promise<unknown>;
    getTenants: (templateId: string) => Promise<TenantBasicDto[]>;
    getApplications: (templateId: string) => Promise<TemplateApplicationEnrichedDto[]>;
    getAvailableApplications: (templateId: string) => Promise<AvailableApplicationDto[]>;
    updateApplicationAccessLevel: (templateId: string, appId: string, accessLevel: ApplicationAccessLevel) => Promise<unknown>;
    getApplicationModules: (templateId: string, appId: string) => Promise<TemplateAppModuleTreeDto[]>;
    updateApplicationModules: (templateId: string, appId: string, request: UpdateTemplateAppModulesRequest) => Promise<unknown>;
    getAiInstances: (templateId: string) => Promise<TemplateAiInstanceDto[]>;
    assignAiInstance: (templateId: string, instanceId: string) => Promise<unknown>;
    removeAiInstance: (templateId: string, instanceId: string) => Promise<unknown>;
};
export type TemplatesApi = ReturnType<typeof _createTemplatesApi>;
export declare const createTemplatesApi: (apiContext: ApiContext) => TemplatesApi;
declare const _createOrganisationsApi: (apiContext: ApiContext) => {
    getAll: (params?: {
        page?: number;
        pageSize?: number;
        search?: string;
        countryCode?: string;
        verificationStatus?: VerificationStatus;
        sortBy?: string;
        sortDesc?: boolean;
    }) => Promise<PaginatedResult<OrganisationListItemDto>>;
    getAvailable: (search?: string) => Promise<OrganisationListItemDto[]>;
    getPendingVerification: () => Promise<OrganisationListItemDto[]>;
    getById: (id: string) => Promise<OrganisationDto>;
    /** Like getById but returns null on 404 instead of throwing (avoids browser console noise) */
    findById: (id: string) => Promise<OrganisationDto | null>;
    create: (data: CreateOrganisationRequest) => Promise<OrganisationDto>;
    updateContact: (id: string, data: {
        phone?: string;
        email?: string;
        website?: string;
    }) => Promise<OrganisationDto>;
    updateAddress: (id: string, data: CreateAddressRequest) => Promise<OrganisationDto>;
    verify: (id: string, notes?: string) => Promise<OrganisationDto>;
    reject: (id: string, reason: string) => Promise<OrganisationDto>;
    /** Lookup company info from official registry (e.g., Zefix for Switzerland) */
    lookup: (countryCode: string, identifier: string) => Promise<CompanyLookupResponse>;
};
export type OrganisationsApi = ReturnType<typeof _createOrganisationsApi>;
export declare const createOrganisationsApi: (apiContext: ApiContext) => OrganisationsApi;
declare const _createMyTenantsApi: (apiContext: ApiContext) => {
    getAll: (search?: string) => Promise<UserTenantDto[]>;
    getDefault: () => Promise<UserTenantDto | null>;
    setDefault: (tenantId: string) => Promise<unknown>;
    clearDefault: () => Promise<unknown>;
    getFavorites: () => Promise<string[]>;
    addFavorite: (tenantId: string) => Promise<string[]>;
    removeFavorite: (tenantId: string) => Promise<string[]>;
    recordRecent: (tenantId: string) => Promise<unknown>;
};
export type MyTenantsApi = ReturnType<typeof _createMyTenantsApi>;
export declare const createMyTenantsApi: (apiContext: ApiContext) => MyTenantsApi;
export {};
//# sourceMappingURL=tenants.d.ts.map