import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
import { Collection, Link, Object as Object$1 } from "./vocab-BCWe1Ih5.js";
import { TracerProvider } from "@opentelemetry/api";
import { DocumentLoader, GetUserAgentOptions } from "@fedify/vocab-runtime";

//#region src/vocab/lookup.d.ts
/**
 * Options for the {@link lookupObject} function.
 *
 * @since 0.2.0
 */
interface LookupObjectOptions {
  /**
   * The document loader for loading remote JSON-LD documents.
   */
  documentLoader?: DocumentLoader;
  /**
   * The context loader for loading remote JSON-LD contexts.
   * @since 0.8.0
   */
  contextLoader?: DocumentLoader;
  /**
   * Whether to allow fetching an object with an `@id` having a different
   * origin than the object's URL.  This is not recommended, as it may
   * lead to security issues.  Only use this option if you know what you
   * are doing.
   *
   * How to handle the case when an object's `@id` has a different origin
   * than the object's URL:
   *
   *  -  `"ignore"` (default): Do not return the object, and log a warning.
   *  -  `"throw"`: Throw an error.
   *  -  `"trust"`: Bypass the check and return the object anyway.  This
   *     is not recommended, as it may lead to security issues.  Only use
   *     this option if you know what you are doing.
   *
   * @since 1.9.0
   */
  crossOrigin?: "ignore" | "throw" | "trust";
  /**
   * The options for making `User-Agent` header.
   * If a string is given, it is used as the `User-Agent` header value.
   * If an object is given, it is passed to {@link getUserAgent} to generate
   * the `User-Agent` header value.
   * @since 1.3.0
   */
  userAgent?: GetUserAgentOptions | string;
  /**
   * The OpenTelemetry tracer provider.  If omitted, the global tracer provider
   * is used.
   * @since 1.3.0
   */
  tracerProvider?: TracerProvider;
  /**
   * AbortSignal for cancelling the request.
   * @since 1.8.0
   */
  signal?: AbortSignal;
}
/**
 * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
 * or a fediverse handle (e.g., `@user@server` or `user@server`).
 *
 * @example
 * ``` typescript
 * // Look up an actor by its fediverse handle:
 * await lookupObject("@hongminhee@fosstodon.org");
 * // returning a `Person` object.
 *
 * // A fediverse handle can omit the leading '@':
 * await lookupObject("hongminhee@fosstodon.org");
 * // returning a `Person` object.
 *
 * // A `acct:` URI can be used as well:
 * await lookupObject("acct:hongminhee@fosstodon.org");
 * // returning a `Person` object.
 *
 * // Look up an object by its URI:
 * await lookupObject("https://todon.eu/@hongminhee/112060633798771581");
 * // returning a `Note` object.
 *
 * // It can be a `URL` object as well:
 * await lookupObject(new URL("https://todon.eu/@hongminhee/112060633798771581"));
 * // returning a `Note` object.
 * ```
 *
 * @param identifier The URI or fediverse handle to look up.
 * @param options Lookup options.
 * @returns The object, or `null` if not found.
 * @since 0.2.0
 */
declare function lookupObject(identifier: string | URL, options?: LookupObjectOptions): Promise<Object$1 | null>;
/**
 * Options for the {@link traverseCollection} function.
 * @since 1.1.0
 */
interface TraverseCollectionOptions {
  /**
   * The document loader for loading remote JSON-LD documents.
   */
  documentLoader?: DocumentLoader;
  /**
   * The context loader for loading remote JSON-LD contexts.
   */
  contextLoader?: DocumentLoader;
  /**
   * Whether to suppress errors when fetching pages.  If `true`,
   * errors will be logged but not thrown.  Defaults to `false`.
   */
  suppressError?: boolean;
  /**
   * The interval to wait between fetching pages.  Zero or negative
   * values will disable the interval.  Disabled by default.
   *
   * @default `{ seconds: 0 }`
   */
  interval?: Temporal.Duration | Temporal.DurationLike;
}
/**
 * Traverses a collection, yielding each item in the collection.
 * If the collection is paginated, it will fetch the next page
 * automatically.
 *
 * @example
 * ``` typescript
 * const collection = await lookupObject(collectionUrl);
 * if (collection instanceof Collection) {
 *   for await (const item of traverseCollection(collection)) {
 *     console.log(item.id?.href);
 *   }
 * }
 * ```
 *
 * @param collection The collection to traverse.
 * @param options Options for traversing the collection.
 * @returns An async iterable of each item in the collection.
 * @since 1.1.0
 */
declare function traverseCollection(collection: Collection, options?: TraverseCollectionOptions): AsyncIterable<Object$1 | Link>;
//#endregion
//#region src/vocab/constants.d.ts
/**
 * The special public collection for [public addressing].  *Do not mutate this
 * object.*
 *
 * [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
 *
 * @since 0.7.0
 */
declare const PUBLIC_COLLECTION: URL;
//#endregion
//#region src/vocab/handle.d.ts
/**
 * Represents a fediverse handle, which consists of a username and a host.
 * The username can be alphanumeric and may include special characters,
 * while the host is typically a domain name.
 * @since 1.8.0
 */
interface FediverseHandle {
  /**
   * The username part of the fediverse handle.
   * It can include alphanumeric characters and some special characters.
   */
  readonly username: string;
  /**
   * The host part of the fediverse handle, typically a domain name.
   * It is the part after the `@` symbol in the handle.
   */
  readonly host: string;
}
/**
 * Parses a fediverse handle in the format `@user@server` or `user@server`.
 * The `user` part can contain alphanumeric characters and some special
 * characters except `@`.  The `server` part is all characters after the `@`
 * symbol in the middle.
 *
 * @example
 * ```typescript
 * const handle = parseFediverseHandle("@username@example.com");
 * console.log(handle?.username); // "username"
 * console.log(handle?.host);     // "example.com"
 * ```
 *
 * @param handle - The fediverse handle string to parse.
 * @returns A {@link FediverseHandle} object with `username` and `host`
 *          if the input is valid; otherwise `null`.
 * @since 1.8.0
 */
declare function parseFediverseHandle(handle: string): FediverseHandle | null;
/**
 * Checks if a string is a valid fediverse handle in the format `@user@server`
 * or `user@server`.  The `user` part can contain alphanumeric characters and
 * some special characters except `@`.  The `server` part is all characters
 * after the `@` symbol in the middle.
 *
 * @example
 * ```typescript
 * console.log(isFediverseHandle("@username@example.com")); // true
 * console.log(isFediverseHandle("username@example.com"));  // true
 * console.log(isFediverseHandle("@username@"));            // false
 * ```
 *
 * @param handle - The string to test as a fediverse handle.
 * @returns `true` if the string matches the fediverse handle pattern;
 *          otherwise `false`.
 * @since 1.8.0
 */
declare function isFediverseHandle(handle: string): handle is `${string}@${string}`;
/**
 * Converts a fediverse handle in the format `@user@server` or `user@server`
 * to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
 *
 * @example
 * ```typescript
 * const identifier = toAcctUrl("@username@example.com");
 * console.log(identifier?.href); // "acct:username@example.com"
 * ```
 *
 * @param handle - The fediverse handle string to convert.
 * @returns A `URL` object representing the `acct:` URI if conversion succeeds;
 *          otherwise `null`.
 * @since 1.8.0
 */
declare function toAcctUrl(handle: string): URL | null;
//#endregion
//#region src/vocab/type.d.ts
/**
 * Returns the type URI of the given object.
 *
 * @example
 * ``` typescript
 * import { getTypeId, Person } from "@fedify/fedify";
 *
 * const obj = new Person({});
 * console.log(getTypeId(obj));
 * // => new URL("https://www.w3.org/ns/activitystreams#Person")
 * ```
 *
 * @param object The Activity Vocabulary object.
 * @returns The type URI of the object, e.g.,
 *          `new URL("https://www.w3.org/ns/activitystreams#Person")`.
 *          If the given `object` is `null` or `undefined`, returns `null` or
 *          `undefined`, respectively.
 * @since 1.3.0
 */
declare function getTypeId(object: Object$1 | Link): URL;
/**
 * Returns the type URI of the given object.
 *
 * @example
 * ``` typescript
 * import { getTypeId, Person } from "@fedify/fedify";
 *
 * const obj = new Person({});
 * console.log(getTypeId(obj));
 * // => new URL("https://www.w3.org/ns/activitystreams#Person")
 * ```
 *
 * @param object The Activity Vocabulary object.
 * @returns The type URI of the object, e.g.,
 *          `new URL("https://www.w3.org/ns/activitystreams#Person")`.
 *          If the given `object` is `null` or `undefined`, returns `null` or
 *          `undefined`, respectively.
 * @since 1.3.0
 */
declare function getTypeId(object: Object$1 | Link | undefined): URL | undefined;
/**
 * Returns the type URI of the given object.
 *
 * @example
 * ``` typescript
 * import { getTypeId, Person } from "@fedify/fedify";
 *
 * const obj = new Person({});
 * console.log(getTypeId(obj));
 * // => new URL("https://www.w3.org/ns/activitystreams#Person")
 * ```
 *
 * @param object The Activity Vocabulary object.
 * @returns The type URI of the object, e.g.,
 *          `new URL("https://www.w3.org/ns/activitystreams#Person")`.
 *          If the given `object` is `null` or `undefined`, returns `null` or
 *          `undefined`, respectively.
 * @since 1.3.0
 */
declare function getTypeId(object: Object$1 | Link | null): URL | null;
/**
 * Returns the type URI of the given object.
 *
 * @example
 * ``` typescript
 * import { getTypeId, Person } from "@fedify/fedify";
 *
 * const obj = new Person({});
 * console.log(getTypeId(obj));
 * // => new URL("https://www.w3.org/ns/activitystreams#Person")
 * ```
 *
 * @param object The Activity Vocabulary object.
 * @returns The type URI of the object, e.g.,
 *          `new URL("https://www.w3.org/ns/activitystreams#Person")`.
 *          If the given `object` is `null` or `undefined`, returns `null` or
 *          `undefined`, respectively.
 * @since 1.3.0
 */
declare function getTypeId(object: Object$1 | Link | null | undefined): URL | null | undefined;
//#endregion
export { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection };