import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
import { i as KvStoreSetOptions, n as KvStore, t as KvKey } from "../kv-C6UC8M9S.js";
import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, r as MessageQueue } from "../mq-D_ZZRdby.js";

//#region src/x/cfworkers.d.ts
type WorkersQueueContentType = "bytes" | "json" | "text" | "v8";
interface WorkersKvGetWithMetadataResult<Value, Metadata> {
  value: Value | null;
  metadata: Metadata | null;
}
interface WorkersKvPutOptions {
  expirationTtl?: number;
  metadata?: unknown;
}
interface WorkersKvNamespace<Key extends string = string> {
  getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<WorkersKvGetWithMetadataResult<ExpectedValue, Metadata>>;
  put(key: Key, value: string, options?: WorkersKvPutOptions): Promise<void>;
  delete(key: Key): Promise<void>;
}
interface WorkersQueueSendOptions {
  contentType?: WorkersQueueContentType;
  delaySeconds?: number;
}
interface WorkersQueueSendBatchOptions {
  delaySeconds?: number;
}
interface WorkersMessageSendRequest<Body = unknown> {
  body: Body;
  contentType?: WorkersQueueContentType;
}
interface WorkersQueue<Body = unknown> {
  send(body: Body, options?: WorkersQueueSendOptions): Promise<void>;
  sendBatch(requests: WorkersMessageSendRequest<Body>[], options?: WorkersQueueSendBatchOptions): Promise<void>;
}
/**
 * Implementation of the {@link KvStore} interface for Cloudflare Workers KV
 * binding.  This class provides a wrapper around Cloudflare's KV namespace to
 * store and retrieve JSON-serializable values using structured keys.
 *
 * Note that this implementation does not support the {@link KvStore.cas}
 * operation, as Cloudflare Workers KV does not support atomic compare-and-swap
 * operations.  If you need this functionality, consider using a different
 * key–value store that supports atomic operations.
 *
 * @deprecated This class has been moved to `@fedify/cfworkers` package.
 *             Import `WorkersKvStore` from `@fedify/cfworkers` instead.
 *             This class will be removed in Fedify v2.0.
 * @since 1.6.0
 */
declare class WorkersKvStore implements KvStore {
  #private;
  constructor(namespace: WorkersKvNamespace<string>);
  get<T = unknown>(key: KvKey): Promise<T | undefined>;
  set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
  delete(key: KvKey): Promise<void>;
}
/**
 * Implementation of the {@link MessageQueue} interface for Cloudflare
 * Workers Queues binding.  This class provides a wrapper around Cloudflare's
 * Queues to send messages to a queue.
 *
 * Note that this implementation does not support the `listen()` method,
 * as Cloudflare Workers Queues do not support message consumption in the same
 * way as other message queue systems.  Instead, you should use
 * the {@link Federation.processQueuedTask} method to process messages
 * passed to the queue.
 *
 * @deprecated This class has been moved to `@fedify/cfworkers` package.
 *             Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
 *             This class will be removed in Fedify v2.0.
 * @since 1.6.0
 */
declare class WorkersMessageQueue implements MessageQueue {
  #private;
  /**
   * Cloudflare Queues provide automatic retry with exponential backoff
   * and Dead Letter Queues.
   * @since 1.7.0
   */
  readonly nativeRetrial = true;
  constructor(queue: WorkersQueue);
  enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
  enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
  listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
}
//#endregion
export { WorkersKvStore, WorkersMessageQueue };