/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import React, { type ReactNode } from 'react';
import type { BaseApplication } from './BaseApplication';
import type { RouteType } from './RouterManager';
export declare const ADMIN_SETTINGS_KEY = "admin.settings.";
export declare const ADMIN_SETTINGS_PATH = "/admin/settings/";
export declare const SNIPPET_PREFIX = "pm.";
export interface PluginSettingsMenuItemOptions {
    key: string;
    title?: React.ReactNode;
    icon?: string | ReactNode;
    /**
     * sort, the smaller the number, the higher the priority
     *
     * @default 0
     */
    sort?: number;
    aclSnippet?: string;
    isPinned?: boolean;
    hidden?: boolean;
    showTabs?: boolean;
    [index: string]: any;
}
export interface PluginSettingsPageItemOptions {
    menuKey: string;
    key: string;
    title?: React.ReactNode;
    Component?: RouteType['Component'];
    componentLoader?: RouteType['componentLoader'];
    sort?: number;
    aclSnippet?: string;
    link?: string;
    hidden?: boolean;
    [index: string]: any;
}
export interface PluginSettingsPageType {
    readonly label?: React.ReactNode;
    readonly title?: React.ReactNode;
    readonly link?: string;
    readonly key: string;
    readonly menuKey: string;
    readonly pageKey?: string;
    readonly pluginKey?: string;
    readonly icon?: ReactNode;
    readonly path: string;
    readonly sort?: number;
    readonly name: string;
    readonly isAllow: boolean;
    readonly isTopLevel: boolean;
    readonly topLevelName: string;
    readonly aclSnippet: string | null;
    readonly isPinned?: boolean;
    readonly hidden?: boolean;
    readonly showTabs?: boolean;
    readonly Component?: RouteType['Component'];
    readonly componentLoader?: RouteType['componentLoader'];
    readonly children?: readonly PluginSettingsPageType[];
    readonly [index: string]: any;
}
interface InternalMenuItemRecord extends PluginSettingsMenuItemOptions {
    name: string;
    Component: RouteType['Component'];
}
interface InternalPageItemRecord extends PluginSettingsPageItemOptions {
    name: string;
}
/**
 * Client V2 settings 注册与查询管理器。
 *
 * 内部仅维护两层结构：menu item 与 page item。
 * 对外继续暴露稳定的查询接口，返回克隆后的快照，避免消费侧意外污染内部状态。
 *
 * @example
 * ```typescript
 * app.pluginSettingsManager.addMenuItem({ key: 'system-settings', title: 'System settings' });
 * app.pluginSettingsManager.addPageTabItem({ menuKey: 'system-settings', key: 'index', componentLoader: async () => ({ default: Page }) });
 * ```
 */
export declare class PluginSettingsManager<TApp extends BaseApplication<any> = BaseApplication<any>> {
    protected menus: Record<string, InternalMenuItemRecord>;
    protected pages: Record<string, InternalPageItemRecord>;
    protected aclSnippets: string[];
    app: TApp;
    private cachedList;
    constructor(app: TApp);
    /**
     * 清理查询缓存。
     *
     * @returns {void}
     */
    clearCache(): void;
    /**
     * 设置 ACL snippets。
     *
     * @param {string[]} aclSnippets 当前角色的 snippets
     * @returns {void}
     */
    setAclSnippets(aclSnippets: string[]): void;
    /**
     * 获取指定 settings 项的 ACL snippet。
     *
     * @param {string} name settings 名称
     * @returns {string | null} ACL snippet
     */
    getAclSnippet(name: string): string;
    /**
     * 获取 route id。
     *
     * @param {string} name settings 名称
     * @returns {string} route id
     */
    getRouteName(name: string): string;
    /**
     * 获取 settings 对应的绝对路径。
     *
     * @param {string} name menu 或 page 名称
     * @returns {string} settings 绝对路径
     */
    getRoutePath(name: string): string;
    /**
     * 注册或更新 menu item。
     *
     * @param {PluginSettingsMenuItemOptions} options menu 配置
     * @returns {void}
     * @throws {Error} 当路径与其他配置冲突时抛错
     */
    addMenuItem(options: PluginSettingsMenuItemOptions): void;
    /**
     * 注册或更新 page item。
     *
     * @param {PluginSettingsPageItemOptions} options page 配置
     * @returns {void}
     * @throws {Error} 当 menu 不存在或路径冲突时抛错
     */
    addPageTabItem(options: PluginSettingsPageItemOptions): void;
    /**
     * 删除 menu 或 page。
     *
     * 删除 menu 时会级联删除其下全部 pages；删除 page 时仅删除单页。
     *
     * @param {string} name menu 或 page 名称
     * @returns {void}
     */
    remove(name: string): void;
    /**
     * 判断当前 settings 是否有权限访问。
     *
     * @param {string} name settings 名称
     * @returns {boolean} 是否允许访问
     */
    hasAuth(name: string): boolean;
    /**
     * 判断指定 settings 是否已注册。
     *
     * 该判断不受 ACL 与 hidden 影响。
     *
     * @param {string} name menu 或 page 名称
     * @returns {boolean} 是否已注册
     */
    has(name: string): boolean;
    /**
     * 获取单个 menu 或 page 的只读快照。
     *
     * @param {string} name menu 或 page 名称
     * @param {boolean} [filterAuth=true] 是否按 ACL 过滤
     * @returns {PluginSettingsPageType | null} 快照结果
     */
    get(name: string, filterAuth?: boolean): PluginSettingsPageType | null;
    /**
     * 获取顶级 menu 列表的只读快照。
     *
     * @param {boolean} [filterAuth=true] 是否按 ACL 过滤
     * @returns {PluginSettingsPageType[]} 顶级 menu 列表
     */
    getList(filterAuth?: boolean): PluginSettingsPageType[];
    /**
     * 获取全部已注册 settings 的 ACL snippets。
     *
     * @returns {(string | null)[]} ACL snippets
     */
    getAclSnippets(): string[];
    protected renderIcon(icon: PluginSettingsMenuItemOptions['icon']): ReactNode;
    private buildSnapshot;
    private buildMenuSnapshot;
    private buildPageSnapshot;
    private cloneSnapshot;
    private sortMenuNames;
    private sortPageNames;
    private getPageNamesByMenu;
    private getPageName;
    private parseName;
    private syncMenuRoute;
    private syncPageRoute;
    private assertIndexConflict;
    private assertPathConflict;
    private isMenuIndexPair;
    private assertMenuKey;
}
export {};
