import * as i0 from '@angular/core';
import { InjectionToken, Provider } from '@angular/core';
import { AXPEntity, AXPMenuProvider, AXPMenuProviderContext, AXPSearchCommandProvider, AXPSearchResult, AXPSettingDefinitionProvider, AXPSettingDefinitionProviderContext } from '@acorex/platform/common';
import { AXPEntityDefinitionLoader, AXPEntityDefinitionPreloader, AXPEntityPreloadEntity } from '@acorex/platform/layout/entity';

declare class AXMIdentifierManagementModule {
    static ɵfac: i0.ɵɵFactoryDeclaration<AXMIdentifierManagementModule, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<AXMIdentifierManagementModule, never, never, never>;
    static ɵinj: i0.ɵɵInjectorDeclaration<AXMIdentifierManagementModule>;
}

declare const RootConfig: {
    config: {
        i18n: string;
    };
    module: {
        module: string;
        name: string;
        title: string;
        icon: string;
    };
    entities: {};
};

declare class AXMEntityProvider implements AXPEntityDefinitionLoader, AXPEntityDefinitionPreloader {
    private injector;
    preload(): AXPEntityPreloadEntity[];
    get(moduleName: string, entityName: string): Promise<AXPEntity | null>;
    static ɵfac: i0.ɵɵFactoryDeclaration<AXMEntityProvider, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AXMEntityProvider>;
}

declare class AXMMenuProvider implements AXPMenuProvider {
    private entityService;
    provide(context: AXPMenuProviderContext): Promise<void>;
}

declare class AXMSearchCommandProvider extends AXPSearchCommandProvider {
    commands: AXPSearchResult[];
}

declare class AXMSettingProvider implements AXPSettingDefinitionProvider {
    provide(context: AXPSettingDefinitionProviderContext): Promise<void>;
}

interface AXPIdentifierRequest {
    /** Identifier id, e.g. 'employee-code' */
    id: string;
    /** Optional tenant partition */
    tenantId?: string;
    /** Optional application partition */
    appId?: string;
    /** Arbitrary payload for tokens to read from */
    payload?: Record<string, unknown>;
}
interface AXPIdentifierResult {
    code: string;
    ruleId: string;
    scopeHash: string;
    consumed: boolean;
    meta?: Record<string, unknown>;
}
interface AXPIdentifierPeekResult extends AXPIdentifierResult {
    consumed: false;
    commitToken: string;
}
interface AXPIdentifierRule {
    id: string;
    title: string;
    entity: string;
    pattern: string;
    enabled: boolean;
    priority: number;
    scopeConfig: {
        byTenant?: boolean;
        byApp?: boolean;
        period?: 'none' | 'daily' | 'monthly' | 'yearly' | {
            format: string;
        };
        customKeys?: string[];
        resetPolicy?: 'never' | 'daily' | 'monthly' | 'yearly' | {
            format: string;
        };
        minValue?: number;
        blockSize?: number;
    };
}
declare abstract class AXPIdentifierService {
    abstract generate(req: AXPIdentifierRequest): Promise<AXPIdentifierResult>;
    abstract peek(req: AXPIdentifierRequest): Promise<AXPIdentifierPeekResult>;
    abstract validate(code: string, entity: string, tenantId?: string): Promise<boolean>;
    abstract commitWithToken(token: string): Promise<AXPIdentifierResult>;
    /** Optional helper for manual codes; stricter and may reject if not next sequence */
    abstract commitByCode(req: AXPIdentifierRequest, code: string): Promise<AXPIdentifierResult>;
}
declare const AXP_IDENTIFIER_SERVICE: InjectionToken<AXPIdentifierService>;
declare const AXP_IDENTIFIER_RULES: InjectionToken<AXPIdentifierRule[]>;

interface AXPPatternToken {
    name: string;
    args: string[];
    raw: string;
    index: number;
}
interface AXPEvalServices {
    sequence: AXPSequenceProvider;
    checksum: AXPChecksumProvider;
    lookup?: AXPLookupProvider;
    policy?: AXPPolicyProvider;
    clock?: AXPClockProvider;
}
interface AXPEvalContext {
    pattern: string;
    request: AXPIdentifierRequest;
    cache: Map<string, unknown>;
    now: Date;
    services: AXPEvalServices;
    evaluationMode: 'preview' | 'commit';
}
interface AXPTokenHandler {
    readonly name: string;
    readonly priority?: number;
    validate?(token: AXPPatternToken): void | never;
    eval(token: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    meta?: {
        title?: string;
        description?: string;
        category?: string;
        examples?: string[];
        argHints?: string[];
        version?: string;
    };
}
interface AXPTokenRegistry {
    register(handler: AXPTokenHandler): void;
    unregister(name: string): void;
    get(name: string): AXPTokenHandler | undefined;
    list(): AXPTokenHandler[];
}
interface AXPSequenceProvider {
    next(scopeHash: string, ruleId: string, options?: {
        pad?: number;
        consume?: boolean;
    }): Promise<number>;
}
interface AXPChecksumProvider {
    compute(algo: 'luhn' | 'mod11', input: string): string;
}
interface AXPLookupProvider {
    get(key: string, params?: Record<string, unknown>): Promise<string | undefined>;
}
interface AXPPolicyProvider {
    isAllowed(tokenName: string, request: AXPIdentifierRequest): boolean;
}
interface AXPClockProvider {
    now(): Date;
}
declare const AXP_TOKEN_HANDLERS: InjectionToken<AXPTokenHandler[]>;

type AXPCompiledFragment = AXPPatternToken | {
    type: 'literal';
    text: string;
};
interface AXPCompiledPattern {
    pattern: string;
    tokens: AXPCompiledFragment[];
}
interface AXPPatternEngine {
    compile(pattern: string): AXPCompiledPattern;
    evaluate(compiled: AXPCompiledPattern, ctx: AXPEvalContext): Promise<string>;
}
declare class AXPSimplePatternEngine implements AXPPatternEngine {
    private readonly registry;
    compile(pattern: string): AXPCompiledPattern;
    evaluate(compiled: AXPCompiledPattern, ctx: AXPEvalContext): Promise<string>;
}

declare class AXPTokenRegistryService implements AXPTokenRegistry {
    private readonly handlers;
    private readonly providerHandlers;
    register(handler: AXPTokenHandler): void;
    unregister(name: string): void;
    get(name: string): AXPTokenHandler | undefined;
    list(): AXPTokenHandler[];
    static ɵfac: i0.ɵɵFactoryDeclaration<AXPTokenRegistryService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AXPTokenRegistryService>;
}

declare class DateToken implements AXPTokenHandler {
    readonly name = "date";
    readonly meta: {
        title: string;
        description: string;
        argHints: string[];
    };
    eval(token: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<DateToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<DateToken>;
}
declare class ConstToken implements AXPTokenHandler {
    readonly name = "const";
    readonly meta: {
        title: string;
        description: string;
    };
    eval(token: AXPPatternToken): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<ConstToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<ConstToken>;
}
declare class FieldToken implements AXPTokenHandler {
    readonly name = "field";
    readonly meta: {
        title: string;
        description: string;
    };
    eval(token: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<FieldToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<FieldToken>;
}
declare class TenantToken implements AXPTokenHandler {
    readonly name = "tenant";
    readonly meta: {
        title: string;
        description: string;
    };
    eval(_t: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<TenantToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<TenantToken>;
}
declare class AppToken implements AXPTokenHandler {
    readonly name = "app";
    readonly meta: {
        title: string;
        description: string;
    };
    eval(_t: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<AppToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AppToken>;
}
declare class SeqToken implements AXPTokenHandler {
    readonly name = "seq";
    readonly meta: {
        title: string;
        description: string;
        argHints: string[];
    };
    eval(token: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<SeqToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<SeqToken>;
}
declare class CheckToken implements AXPTokenHandler {
    readonly name = "check";
    readonly meta: {
        title: string;
        description: string;
        argHints: string[];
    };
    eval(token: AXPPatternToken, ctx: AXPEvalContext): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<CheckToken, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<CheckToken>;
}

declare const AXP_DEFAULT_TOKEN_PROVIDERS: Provider[];

declare function buildScopeHash(parts: Array<string | undefined>): string;
declare function padNumber(num: number, size: number): string;
declare function uuid(): string;

export { AXMEntityProvider, AXMIdentifierManagementModule, AXMMenuProvider, AXMSearchCommandProvider, AXMSettingProvider, AXPIdentifierService, AXPSimplePatternEngine, AXPTokenRegistryService, AXP_DEFAULT_TOKEN_PROVIDERS, AXP_IDENTIFIER_RULES, AXP_IDENTIFIER_SERVICE, AXP_TOKEN_HANDLERS, AppToken, CheckToken, ConstToken, DateToken, FieldToken, RootConfig, SeqToken, TenantToken, buildScopeHash, padNumber, uuid };
export type { AXPChecksumProvider, AXPClockProvider, AXPCompiledFragment, AXPCompiledPattern, AXPEvalContext, AXPEvalServices, AXPIdentifierPeekResult, AXPIdentifierRequest, AXPIdentifierResult, AXPIdentifierRule, AXPLookupProvider, AXPPatternEngine, AXPPatternToken, AXPPolicyProvider, AXPSequenceProvider, AXPTokenHandler, AXPTokenRegistry };
