import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";

//#region src/federation/kv.d.ts
/**
 * A key for a key–value store.  An array of one or more strings.
 *
 * @since 0.5.0
 */
type KvKey = readonly [string] | readonly [string, ...string[]];
/**
 * Additional options for setting a value in a key–value store.
 *
 * @since 0.5.0
 */
interface KvStoreSetOptions {
  /**
   * The time-to-live (TTL) for the value.
   */
  ttl?: Temporal.Duration;
}
/**
 * An abstract interface for a key–value store.
 *
 * @since 0.5.0
 */
interface KvStore {
  /**
   * Gets the value for the given key.
   * @param key The key to get the value for.
   * @returns The value for the key, or `undefined` if the key does not exist.
   * @template T The type of the value to get.
   */
  get<T = unknown>(key: KvKey): Promise<T | undefined>;
  /**
   * Sets the value for the given key.
   * @param key The key to set the value for.
   * @param value The value to set.
   * @param options Additional options for setting the value.
   */
  set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
  /**
   * Deletes the value for the given key.
   * @param key The key to delete.
   */
  delete(key: KvKey): Promise<void>;
  /**
   * Compare-and-swap (CAS) operation for the key–value store.
   * @param key The key to perform the CAS operation on.
   * @param expectedValue The expected value for the key.
   * @param newValue The new value to set if the expected value matches.
   * @param options Additional options for setting the value.
   * @return `true` if the CAS operation was successful, `false` otherwise.
   * @since 1.8.0
   */
  cas?: (key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions) => Promise<boolean>;
}
/**
 * A key–value store that stores values in memory.
 * Do not use this in production as it does not persist values.
 *
 * @since 0.5.0
 */
declare class MemoryKvStore implements KvStore {
  #private;
  /**
   * {@inheritDoc KvStore.get}
   */
  get<T = unknown>(key: KvKey): Promise<T | undefined>;
  /**
   * {@inheritDoc KvStore.set}
   */
  set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
  /**
   * {@inheritDoc KvStore.delete}
   */
  delete(key: KvKey): Promise<void>;
  /**
   * {@inheritDoc KvStore.cas}
   */
  cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
}
//#endregion
export { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore };