import { TypedFn } from '../internals/types.cjs';
import '../internals/helpers/guards.cjs';

/**
 * Copyright 2025 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

type Instance = NonNullable<any>;
type CacheKeyFn = (this: Instance, ...args: any[]) => string;
interface CacheDecoratorOptions {
    enabled: boolean;
    ttl?: number;
    cacheKey: CacheKeyFn;
    enumerable?: boolean;
}
interface CacheEntry {
    expiresAt: number;
    data: any;
}
interface CacheDecoratorInstance {
    get(key?: string): CacheEntry | undefined;
    clear(keys?: string[]): void;
    isEnabled(): boolean;
    enable(): void;
    disable(): void;
    update(data: Partial<CacheDecoratorOptions>): void;
}
declare function Cache(_options?: Partial<CacheDecoratorOptions>): (obj: NonNullable<object>, key: string | symbol, descriptor: PropertyDescriptor) => void;
declare namespace Cache {
    var init: <T extends NonNullable<unknown>>(self: T) => void;
    var getInstance: <T extends NonNullable<unknown>>(target: T, property: keyof T) => CacheDecoratorInstance;
}
declare const WeakRefKeyFn: {
    (...args: any[]): string;
    from<T>(cb: (self: T) => any[]): (this: T) => string;
};
declare const ObjectHashKeyFn: CacheKeyFn;
declare const JSONCacheKeyFn: CacheKeyFn;
declare const SingletonCacheKeyFn: CacheKeyFn;
declare class CacheFn<P extends any[], R> extends Function {
    protected readonly fn: (...args: P) => R;
    protected readonly options?: Partial<CacheDecoratorOptions> | undefined;
    readonly name: string;
    static create<A extends any[], B>(fn: (...args: A) => B, options?: Partial<CacheDecoratorOptions>): TypedFn<A, B> & CacheFn<A, B>;
    constructor(fn: (...args: P) => R, options?: Partial<CacheDecoratorOptions> | undefined);
    updateTTL(ttl: number): void;
    createSnapshot(): {
        fn: (...args: P) => R;
        options: Partial<CacheDecoratorOptions> | undefined;
    };
    get(...args: P): R;
}

export { Cache, type CacheDecoratorInstance, type CacheDecoratorOptions, CacheFn, JSONCacheKeyFn, ObjectHashKeyFn, SingletonCacheKeyFn, WeakRefKeyFn };
