UNPKG

@fedify/fedify

Version:

An ActivityPub server framework

903 lines (892 loc) • 1.71 MB
import { Temporal } from "@js-temporal/polyfill"; import { URLPattern } from "urlpattern-polyfill"; import { deno_default, getDocumentLoader } from "./docloader-b8Rvguvo.js"; import { lookupWebFinger } from "./lookup-Q9UB5zay.js"; import { getLogger } from "@logtape/logtape"; import { SpanStatusCode, trace } from "@opentelemetry/api"; import jsonld from "jsonld"; import { LanguageTag, parseLanguageTag } from "@phensley/language-tag"; import baseX from "@multiformats/base-x"; import { Integer, Sequence } from "asn1js"; import { decodeBase64, encodeBase64 } from "byte-encodings/base64"; import { decodeBase64Url } from "byte-encodings/base64url"; import { decodeHex } from "byte-encodings/hex"; import { addPrefix, getCodeFromData, rmPrefix } from "multicodec"; import { createPublicKey } from "node:crypto"; import { PublicKeyInfo } from "pkijs"; import { domainToASCII, domainToUnicode } from "node:url"; //#region vocab/type.ts function getTypeId(object) { if (object == null) return object; const cls = object.constructor; return cls.typeId; } //#endregion //#region runtime/multibase/util.ts const textDecoder = new TextDecoder(); const decodeText = (bytes) => textDecoder.decode(bytes); const textEncoder = new TextEncoder(); const encodeText = (text) => textEncoder.encode(text); function concat(arrs, length) { const output = new Uint8Array(length); let offset = 0; for (const arr of arrs) { output.set(arr, offset); offset += arr.length; } return output; } //#endregion //#region runtime/multibase/base.ts /** * Class to encode/decode in the supported Bases */ var Base = class { codeBuf; codec; constructor(name, code, factory, alphabet) { this.name = name; this.code = code; this.alphabet = alphabet; this.codeBuf = encodeText(this.code); this.alphabet = alphabet; this.codec = factory(alphabet); } encode(buf) { return this.codec.encode(buf); } decode(string) { for (const char of string) if (this.alphabet && this.alphabet.indexOf(char) < 0) throw new Error(`invalid character '${char}' in '${string}'`); return this.codec.decode(string); } }; //#endregion //#region runtime/multibase/rfc4648.ts const decode$1 = (string, alphabet, bitsPerChar) => { const codes$1 = {}; for (let i = 0; i < alphabet.length; ++i) codes$1[alphabet[i]] = i; let end = string.length; while (string[end - 1] === "=") --end; const out = new Uint8Array(end * bitsPerChar / 8 | 0); let bits = 0; let buffer = 0; let written = 0; for (let i = 0; i < end; ++i) { const value = codes$1[string[i]]; if (value === void 0) throw new SyntaxError("Invalid character " + string[i]); buffer = buffer << bitsPerChar | value; bits += bitsPerChar; if (bits >= 8) { bits -= 8; out[written++] = 255 & buffer >> bits; } } if (bits >= bitsPerChar || 255 & buffer << 8 - bits) throw new SyntaxError("Unexpected end of data"); return out; }; const encode$1 = (data, alphabet, bitsPerChar) => { const pad = alphabet[alphabet.length - 1] === "="; const mask = (1 << bitsPerChar) - 1; let out = ""; let bits = 0; let buffer = 0; for (let i = 0; i < data.length; ++i) { buffer = buffer << 8 | data[i]; bits += 8; while (bits > bitsPerChar) { bits -= bitsPerChar; out += alphabet[mask & buffer >> bits]; } } if (bits) out += alphabet[mask & buffer << bitsPerChar - bits]; if (pad) while (out.length * bitsPerChar & 7) out += "="; return out; }; /** * RFC4648 Factory */ const rfc4648 = (bitsPerChar) => (alphabet) => { return { encode(input) { return encode$1(input, alphabet, bitsPerChar); }, decode(input) { return decode$1(input, alphabet, bitsPerChar); } }; }; //#endregion //#region runtime/multibase/constants.ts const identity = () => { return { encode: decodeText, decode: encodeText }; }; /** * name, code, implementation, alphabet * * @type {Array<[BaseName, BaseCode, CodecFactory, string]>} */ const constants = [ [ "identity", "\0", identity, "" ], [ "base2", "0", rfc4648(1), "01" ], [ "base8", "7", rfc4648(3), "01234567" ], [ "base10", "9", baseX, "0123456789" ], [ "base16", "f", rfc4648(4), "0123456789abcdef" ], [ "base16upper", "F", rfc4648(4), "0123456789ABCDEF" ], [ "base32hex", "v", rfc4648(5), "0123456789abcdefghijklmnopqrstuv" ], [ "base32hexupper", "V", rfc4648(5), "0123456789ABCDEFGHIJKLMNOPQRSTUV" ], [ "base32hexpad", "t", rfc4648(5), "0123456789abcdefghijklmnopqrstuv=" ], [ "base32hexpadupper", "T", rfc4648(5), "0123456789ABCDEFGHIJKLMNOPQRSTUV=" ], [ "base32", "b", rfc4648(5), "abcdefghijklmnopqrstuvwxyz234567" ], [ "base32upper", "B", rfc4648(5), "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" ], [ "base32pad", "c", rfc4648(5), "abcdefghijklmnopqrstuvwxyz234567=" ], [ "base32padupper", "C", rfc4648(5), "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=" ], [ "base32z", "h", rfc4648(5), "ybndrfg8ejkmcpqxot1uwisza345h769" ], [ "base36", "k", baseX, "0123456789abcdefghijklmnopqrstuvwxyz" ], [ "base36upper", "K", baseX, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ], [ "base58btc", "z", baseX, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" ], [ "base58flickr", "Z", baseX, "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" ], [ "base64", "m", rfc4648(6), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ], [ "base64pad", "M", rfc4648(6), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ], [ "base64url", "u", rfc4648(6), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ], [ "base64urlpad", "U", rfc4648(6), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=" ] ]; const names = constants.reduce((prev, tupple) => { prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]); return prev; }, {}); const codes = constants.reduce((prev, tupple) => { prev[tupple[1]] = names[tupple[0]]; return prev; }, {}); //#endregion //#region runtime/multibase/index.ts /** * Encode data with the specified base and add the multibase prefix. * * @throws {Error} Will throw if the encoding is not supported */ function encode(nameOrCode, buf) { const enc = encoding(nameOrCode); const data = encodeText(enc.encode(buf)); return concat([enc.codeBuf, data], enc.codeBuf.length + data.length); } /** * Takes a Uint8Array or string encoded with multibase header, decodes it and * returns the decoded buffer * * @throws {Error} Will throw if the encoding is not supported */ function decode(data) { if (data instanceof Uint8Array) data = decodeText(data); const prefix = data[0]; if ([ "f", "F", "v", "V", "t", "T", "b", "B", "c", "C", "h", "k", "K" ].includes(prefix)) data = data.toLowerCase(); const enc = encoding(data[0]); return enc.decode(data.substring(1)); } /** * Get the encoding by name or code * @throws {Error} Will throw if the encoding is not supported */ function encoding(nameOrCode) { if (Object.prototype.hasOwnProperty.call(names, nameOrCode)) return names[nameOrCode]; else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode]; else throw new Error(`Unsupported encoding: ${nameOrCode}`); } //#endregion //#region runtime/key.ts const algorithms = { "1.2.840.113549.1.1.1": { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, "1.3.101.112": "Ed25519" }; /** * Imports a PEM-SPKI formatted public key. * @param pem The PEM-SPKI formatted public key. * @returns The imported public key. * @throws {TypeError} If the key is invalid or unsupported. * @since 0.5.0 */ async function importSpki(pem) { pem = pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, ""); let spki; try { spki = decodeBase64(pem); } catch (_) { throw new TypeError("Invalid PEM-SPKI format."); } const pki = PublicKeyInfo.fromBER(spki); const oid = pki.algorithm.algorithmId; const algorithm = algorithms[oid]; if (algorithm == null) throw new TypeError("Unsupported algorithm: " + oid); return await crypto.subtle.importKey("spki", spki, algorithm, true, ["verify"]); } /** * Exports a public key in PEM-SPKI format. * @param key The public key to export. * @returns The exported public key in PEM-SPKI format. * @throws {TypeError} If the key is invalid or unsupported. * @since 0.5.0 */ async function exportSpki(key) { const { validateCryptoKey } = await import("./key-CLy1OKnR.js"); validateCryptoKey(key); const spki = await crypto.subtle.exportKey("spki", key); let pem = encodeBase64(spki); pem = (pem.match(/.{1,64}/g) || []).join("\n"); return `-----BEGIN PUBLIC KEY-----\n${pem}\n-----END PUBLIC KEY-----\n`; } /** * Imports a PEM-PKCS#1 formatted public key. * @param pem The PEM-PKCS#1 formatted public key. * @returns The imported public key. * @throws {TypeError} If the key is invalid or unsupported. * @since 1.5.0 */ function importPkcs1(pem) { const key = createPublicKey({ key: pem, format: "pem", type: "pkcs1" }); const spki = key.export({ type: "spki", format: "pem" }); return importSpki(spki); } const PKCS1_HEADER = /^\s*-----BEGIN\s+RSA\s+PUBLIC\s+KEY-----\s*\n/; /** * Imports a PEM formatted public key (SPKI or PKCS#1). * @param pem The PEM formatted public key to import (SPKI or PKCS#1). * @returns The imported public key. * @throws {TypeError} If the key is invalid or unsupported. * @since 1.5.0 */ function importPem(pem) { return PKCS1_HEADER.test(pem) ? importPkcs1(pem) : importSpki(pem); } /** * Imports a [Multibase]-encoded public key. * * [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0 * @param key The Multibase-encoded public key. * @returns The imported public key. * @throws {TypeError} If the key is invalid or unsupported. * @since 0.10.0 */ async function importMultibaseKey(key) { const decoded = decode(key); const code = getCodeFromData(decoded); const content = rmPrefix(decoded); if (code === 4613) { const keyObject = createPublicKey({ key: content, format: "der", type: "pkcs1" }); const spki = keyObject.export({ type: "spki", format: "der" }).buffer; return await crypto.subtle.importKey("spki", new Uint8Array(spki), { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, true, ["verify"]); } else if (code === 237) return await crypto.subtle.importKey("raw", content, "Ed25519", true, ["verify"]); else throw new TypeError("Unsupported key type: 0x" + code.toString(16)); } /** * Exports a public key in [Multibase] format. * * [Multibase]: https://www.w3.org/TR/vc-data-integrity/#multibase-0 * @param key The public key to export. * @returns The exported public key in Multibase format. * @throws {TypeError} If the key is invalid or unsupported. * @since 0.10.0 */ async function exportMultibaseKey(key) { let content; let code; if (key.algorithm.name === "Ed25519") { content = await crypto.subtle.exportKey("raw", key); code = 237; } else if (key.algorithm.name === "RSASSA-PKCS1-v1_5" && key.algorithm.hash.name === "SHA-256") { const jwk = await crypto.subtle.exportKey("jwk", key); const decodedN = decodeBase64Url(jwk.n); const n = new Uint8Array(decodedN.length + 1); n.set(decodedN, 1); const sequence = new Sequence({ value: [new Integer({ isHexOnly: true, valueHex: n }), new Integer({ isHexOnly: true, valueHex: decodeBase64Url(jwk.e) })] }); content = sequence.toBER(false); code = 4613; } else throw new TypeError("Unsupported key type: " + JSON.stringify(key.algorithm)); const codeHex = code.toString(16); const codeBytes = decodeHex(codeHex.length % 2 < 1 ? codeHex : "0" + codeHex); const prefixed = addPrefix(codeBytes, new Uint8Array(content)); const encoded = encode("base58btc", prefixed); return new TextDecoder().decode(encoded); } //#endregion //#region runtime/langstr.ts /** * A language-tagged string which corresponds to the `rdf:langString` type. */ var LanguageString = class extends String { language; /** * Constructs a new `LanguageString`. * @param value A string value written in the given language. * @param language The language of the string. If a string is given, it will * be parsed as a `LanguageTag`. */ constructor(value, language) { super(value); this.language = typeof language === "string" ? parseLanguageTag(language) : language; } [Symbol.for("Deno.customInspect")](inspect, options) { return `<${this.language.compact()}> ${inspect(this.toString(), options)}`; } [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) { return `<${this.language.compact()}> ${inspect(this.toString(), options)}`; } }; //#endregion //#region vocab/vocab.ts /** Describes an object of any kind. The Object type serves as the base type for * most of the other kinds of objects defined in the Activity Vocabulary, * including other Core types such as {@link Activity}, * {@link IntransitiveActivity}, {@link Collection} and * {@link OrderedCollection}. */ var Object$1 = class Object$1 { #documentLoader; #contextLoader; #tracerProvider; #warning; #cachedJsonLd; id; get _documentLoader() { return this.#documentLoader; } get _contextLoader() { return this.#contextLoader; } get _tracerProvider() { return this.#tracerProvider; } get _warning() { return this.#warning; } get _cachedJsonLd() { return this.#cachedJsonLd; } set _cachedJsonLd(value) { this.#cachedJsonLd = value; } /** * The type URI of {@link Object}: `https://www.w3.org/ns/activitystreams#Object`. */ static get typeId() { return new URL("https://www.w3.org/ns/activitystreams#Object"); } #_49BipA5dq9eoH8LX8xdsVumveTca_attachment = []; #_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = []; #_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = []; #_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = []; #_3mhZzGXSpQ431mBSz2kvych22v4e_context = []; #_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = []; #_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime = []; #_86xFhmgBapoMvYqjbjRuDPayTrS_generator = []; #_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = []; #_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = []; #_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = []; #_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = []; #_gCVTegXxWWCw6wWRxa1QF65zusg_preview = []; #_5e258TDXtuhaFRPZiGoDfEpjdMr_published = []; #_7UpwM3JWcXhADcscukEehBorf6k_replies = []; #_3kAfck9PcEYt2L7xug5y99YPbANs_shares = []; #_S3ceDnpMdzoTRCccB9FkJWrEzYW_likes = []; #_kMatyyNAuxoTD8GQMBfA5ogThMR_emojiReactions = []; #_2w3Jmue4up8iVDUA51WZqomEF438_startTime = []; #_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = []; #_5chuqj6s95p5gg2sk1HntGfarRf_tag = []; #_385aB7ySixcf5Un6z3VsWmThgCzQ_updated = []; #_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = []; #_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = []; #_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = []; #_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = []; #_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = []; #_3BLrzmscsjHCw8TF5BHRW9WkPnX8_mediaType = []; #_3bNvLMBN1bCJETiTihM3wvi1B2JX_duration = []; #_u8gdcDTtChQ4tbSQMXc4cYWyum7_sensitive = []; #_2ZwCFoS787v8y8bXKjMoE6MAbrEB_source = []; #_42rPnotok1ivQ2RNCKNbeFJgx8b8_proof = []; /** * Constructs a new instance of Object with the given values. * @param values The values to initialize the instance with. * @param options The options to use for initialization. */ constructor(values, options = {}) { this.#documentLoader = options.documentLoader; this.#contextLoader = options.contextLoader; this.#tracerProvider = options.tracerProvider; if ("$warning" in options) this.#warning = options.$warning; if (values.id == null || values.id instanceof URL) this.id = values.id ?? null; else throw new TypeError("The id must be a URL."); if ("attachments" in values && values.attachments != null) if (Array.isArray(values.attachments) && values.attachments.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof PropertyValue || v instanceof URL)) this.#_49BipA5dq9eoH8LX8xdsVumveTca_attachment = values.attachments; else throw new TypeError("The attachments must be an array of type Object | Link | PropertyValue | URL."); if ("attribution" in values && values.attribution != null) if (values.attribution instanceof Application || values.attribution instanceof Group || values.attribution instanceof Organization || values.attribution instanceof Person || values.attribution instanceof Service || values.attribution instanceof URL) this.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = [values.attribution]; else throw new TypeError("The attribution must be of type Application | Group | Organization | Person | Service | URL."); if ("attributions" in values && values.attributions != null) { if ("attribution" in values && values.attribution != null) throw new TypeError("Cannot initialize both attribution and attributions at the same time."); if (Array.isArray(values.attributions) && values.attributions.every((v) => v instanceof Application || v instanceof Group || v instanceof Organization || v instanceof Person || v instanceof Service || v instanceof URL)) this.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = values.attributions; else throw new TypeError("The attributions must be an array of type Application | Group | Organization | Person | Service | URL."); } if ("audience" in values && values.audience != null) if (values.audience instanceof Object$1 || values.audience instanceof URL) this.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = [values.audience]; else throw new TypeError("The audience must be of type Object | URL."); if ("audiences" in values && values.audiences != null) { if ("audience" in values && values.audience != null) throw new TypeError("Cannot initialize both audience and audiences at the same time."); if (Array.isArray(values.audiences) && values.audiences.every((v) => v instanceof Object$1 || v instanceof URL)) this.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = values.audiences; else throw new TypeError("The audiences must be an array of type Object | URL."); } if ("content" in values && values.content != null) if (typeof values.content === "string" || values.content instanceof LanguageString) this.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = [values.content]; else throw new TypeError("The content must be of type string | LanguageString."); if ("contents" in values && values.contents != null) { if ("content" in values && values.content != null) throw new TypeError("Cannot initialize both content and contents at the same time."); if (Array.isArray(values.contents) && values.contents.every((v) => typeof v === "string" || v instanceof LanguageString)) this.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = values.contents; else throw new TypeError("The contents must be an array of type string | LanguageString."); } if ("contexts" in values && values.contexts != null) if (Array.isArray(values.contexts) && values.contexts.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) this.#_3mhZzGXSpQ431mBSz2kvych22v4e_context = values.contexts; else throw new TypeError("The contexts must be an array of type Object | Link | URL."); if ("name" in values && values.name != null) if (typeof values.name === "string" || values.name instanceof LanguageString) this.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = [values.name]; else throw new TypeError("The name must be of type string | LanguageString."); if ("names" in values && values.names != null) { if ("name" in values && values.name != null) throw new TypeError("Cannot initialize both name and names at the same time."); if (Array.isArray(values.names) && values.names.every((v) => typeof v === "string" || v instanceof LanguageString)) this.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = values.names; else throw new TypeError("The names must be an array of type string | LanguageString."); } if ("endTime" in values && values.endTime != null) if (values.endTime instanceof Temporal.Instant) this.#_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime = [values.endTime]; else throw new TypeError("The endTime must be of type Temporal.Instant."); if ("generators" in values && values.generators != null) if (Array.isArray(values.generators) && values.generators.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) this.#_86xFhmgBapoMvYqjbjRuDPayTrS_generator = values.generators; else throw new TypeError("The generators must be an array of type Object | Link | URL."); if ("icon" in values && values.icon != null) if (values.icon instanceof Image || values.icon instanceof URL) this.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = [values.icon]; else throw new TypeError("The icon must be of type Image | URL."); if ("icons" in values && values.icons != null) { if ("icon" in values && values.icon != null) throw new TypeError("Cannot initialize both icon and icons at the same time."); if (Array.isArray(values.icons) && values.icons.every((v) => v instanceof Image || v instanceof URL)) this.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = values.icons; else throw new TypeError("The icons must be an array of type Image | URL."); } if ("image" in values && values.image != null) if (values.image instanceof Image || values.image instanceof URL) this.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = [values.image]; else throw new TypeError("The image must be of type Image | URL."); if ("images" in values && values.images != null) { if ("image" in values && values.image != null) throw new TypeError("Cannot initialize both image and images at the same time."); if (Array.isArray(values.images) && values.images.every((v) => v instanceof Image || v instanceof URL)) this.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = values.images; else throw new TypeError("The images must be an array of type Image | URL."); } if ("replyTarget" in values && values.replyTarget != null) if (values.replyTarget instanceof Object$1 || values.replyTarget instanceof Link || values.replyTarget instanceof URL) this.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = [values.replyTarget]; else throw new TypeError("The replyTarget must be of type Object | Link | URL."); if ("replyTargets" in values && values.replyTargets != null) { if ("replyTarget" in values && values.replyTarget != null) throw new TypeError("Cannot initialize both replyTarget and replyTargets at the same time."); if (Array.isArray(values.replyTargets) && values.replyTargets.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) this.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = values.replyTargets; else throw new TypeError("The replyTargets must be an array of type Object | Link | URL."); } if ("location" in values && values.location != null) if (values.location instanceof Object$1 || values.location instanceof Link || values.location instanceof URL) this.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = [values.location]; else throw new TypeError("The location must be of type Object | Link | URL."); if ("locations" in values && values.locations != null) { if ("location" in values && values.location != null) throw new TypeError("Cannot initialize both location and locations at the same time."); if (Array.isArray(values.locations) && values.locations.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) this.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = values.locations; else throw new TypeError("The locations must be an array of type Object | Link | URL."); } if ("preview" in values && values.preview != null) if (values.preview instanceof Link || values.preview instanceof Object$1 || values.preview instanceof URL) this.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview = [values.preview]; else throw new TypeError("The preview must be of type Link | Object | URL."); if ("previews" in values && values.previews != null) { if ("preview" in values && values.preview != null) throw new TypeError("Cannot initialize both preview and previews at the same time."); if (Array.isArray(values.previews) && values.previews.every((v) => v instanceof Link || v instanceof Object$1 || v instanceof URL)) this.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview = values.previews; else throw new TypeError("The previews must be an array of type Link | Object | URL."); } if ("published" in values && values.published != null) if (values.published instanceof Temporal.Instant) this.#_5e258TDXtuhaFRPZiGoDfEpjdMr_published = [values.published]; else throw new TypeError("The published must be of type Temporal.Instant."); if ("replies" in values && values.replies != null) if (values.replies instanceof Collection || values.replies instanceof URL) this.#_7UpwM3JWcXhADcscukEehBorf6k_replies = [values.replies]; else throw new TypeError("The replies must be of type Collection | URL."); if ("shares" in values && values.shares != null) if (values.shares instanceof Collection || values.shares instanceof URL) this.#_3kAfck9PcEYt2L7xug5y99YPbANs_shares = [values.shares]; else throw new TypeError("The shares must be of type Collection | URL."); if ("likes" in values && values.likes != null) if (values.likes instanceof Collection || values.likes instanceof URL) this.#_S3ceDnpMdzoTRCccB9FkJWrEzYW_likes = [values.likes]; else throw new TypeError("The likes must be of type Collection | URL."); if ("emojiReactions" in values && values.emojiReactions != null) if (values.emojiReactions instanceof Collection || values.emojiReactions instanceof URL) this.#_kMatyyNAuxoTD8GQMBfA5ogThMR_emojiReactions = [values.emojiReactions]; else throw new TypeError("The emojiReactions must be of type Collection | URL."); if ("startTime" in values && values.startTime != null) if (values.startTime instanceof Temporal.Instant) this.#_2w3Jmue4up8iVDUA51WZqomEF438_startTime = [values.startTime]; else throw new TypeError("The startTime must be of type Temporal.Instant."); if ("summary" in values && values.summary != null) if (typeof values.summary === "string" || values.summary instanceof LanguageString) this.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = [values.summary]; else throw new TypeError("The summary must be of type string | LanguageString."); if ("summaries" in values && values.summaries != null) { if ("summary" in values && values.summary != null) throw new TypeError("Cannot initialize both summary and summaries at the same time."); if (Array.isArray(values.summaries) && values.summaries.every((v) => typeof v === "string" || v instanceof LanguageString)) this.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = values.summaries; else throw new TypeError("The summaries must be an array of type string | LanguageString."); } if ("tags" in values && values.tags != null) if (Array.isArray(values.tags) && values.tags.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) this.#_5chuqj6s95p5gg2sk1HntGfarRf_tag = values.tags; else throw new TypeError("The tags must be an array of type Object | Link | URL."); if ("updated" in values && values.updated != null) if (values.updated instanceof Temporal.Instant) this.#_385aB7ySixcf5Un6z3VsWmThgCzQ_updated = [values.updated]; else throw new TypeError("The updated must be of type Temporal.Instant."); if ("url" in values && values.url != null) if (values.url instanceof URL || values.url instanceof Link) this.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = [values.url]; else throw new TypeError("The url must be of type URL | Link."); if ("urls" in values && values.urls != null) { if ("url" in values && values.url != null) throw new TypeError("Cannot initialize both url and urls at the same time."); if (Array.isArray(values.urls) && values.urls.every((v) => v instanceof URL || v instanceof Link)) this.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = values.urls; else throw new TypeError("The urls must be an array of type URL | Link."); } if ("to" in values && values.to != null) if (values.to instanceof Object$1 || values.to instanceof URL) this.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = [values.to]; else throw new TypeError("The to must be of type Object | URL."); if ("tos" in values && values.tos != null) { if ("to" in values && values.to != null) throw new TypeError("Cannot initialize both to and tos at the same time."); if (Array.isArray(values.tos) && values.tos.every((v) => v instanceof Object$1 || v instanceof URL)) this.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = values.tos; else throw new TypeError("The tos must be an array of type Object | URL."); } if ("bto" in values && values.bto != null) if (values.bto instanceof Object$1 || values.bto instanceof URL) this.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = [values.bto]; else throw new TypeError("The bto must be of type Object | URL."); if ("btos" in values && values.btos != null) { if ("bto" in values && values.bto != null) throw new TypeError("Cannot initialize both bto and btos at the same time."); if (Array.isArray(values.btos) && values.btos.every((v) => v instanceof Object$1 || v instanceof URL)) this.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = values.btos; else throw new TypeError("The btos must be an array of type Object | URL."); } if ("cc" in values && values.cc != null) if (values.cc instanceof Object$1 || values.cc instanceof URL) this.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = [values.cc]; else throw new TypeError("The cc must be of type Object | URL."); if ("ccs" in values && values.ccs != null) { if ("cc" in values && values.cc != null) throw new TypeError("Cannot initialize both cc and ccs at the same time."); if (Array.isArray(values.ccs) && values.ccs.every((v) => v instanceof Object$1 || v instanceof URL)) this.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = values.ccs; else throw new TypeError("The ccs must be an array of type Object | URL."); } if ("bcc" in values && values.bcc != null) if (values.bcc instanceof Object$1 || values.bcc instanceof URL) this.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = [values.bcc]; else throw new TypeError("The bcc must be of type Object | URL."); if ("bccs" in values && values.bccs != null) { if ("bcc" in values && values.bcc != null) throw new TypeError("Cannot initialize both bcc and bccs at the same time."); if (Array.isArray(values.bccs) && values.bccs.every((v) => v instanceof Object$1 || v instanceof URL)) this.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = values.bccs; else throw new TypeError("The bccs must be an array of type Object | URL."); } if ("mediaType" in values && values.mediaType != null) if (typeof values.mediaType === "string") this.#_3BLrzmscsjHCw8TF5BHRW9WkPnX8_mediaType = [values.mediaType]; else throw new TypeError("The mediaType must be of type string."); if ("duration" in values && values.duration != null) if (values.duration instanceof Temporal.Duration) this.#_3bNvLMBN1bCJETiTihM3wvi1B2JX_duration = [values.duration]; else throw new TypeError("The duration must be of type Temporal.Duration."); if ("sensitive" in values && values.sensitive != null) if (typeof values.sensitive === "boolean") this.#_u8gdcDTtChQ4tbSQMXc4cYWyum7_sensitive = [values.sensitive]; else throw new TypeError("The sensitive must be of type boolean."); if ("source" in values && values.source != null) if (values.source instanceof Source) this.#_2ZwCFoS787v8y8bXKjMoE6MAbrEB_source = [values.source]; else throw new TypeError("The source must be of type Source."); if ("proof" in values && values.proof != null) if (values.proof instanceof DataIntegrityProof || values.proof instanceof URL) this.#_42rPnotok1ivQ2RNCKNbeFJgx8b8_proof = [values.proof]; else throw new TypeError("The proof must be of type DataIntegrityProof | URL."); if ("proofs" in values && values.proofs != null) { if ("proof" in values && values.proof != null) throw new TypeError("Cannot initialize both proof and proofs at the same time."); if (Array.isArray(values.proofs) && values.proofs.every((v) => v instanceof DataIntegrityProof || v instanceof URL)) this.#_42rPnotok1ivQ2RNCKNbeFJgx8b8_proof = values.proofs; else throw new TypeError("The proofs must be an array of type DataIntegrityProof | URL."); } } /** * Clones this instance, optionally updating it with the given values. * @param values The values to update the clone with. * @options The options to use for cloning. * @returns The cloned instance. */ clone(values = {}, options = {}) { if (this._warning != null) { getLogger(this._warning.category).warn(this._warning.message, this._warning.values); options = { ...options, $warning: this._warning }; } const clone = new this.constructor({ id: values.id ?? this.id }, options); clone.#_49BipA5dq9eoH8LX8xdsVumveTca_attachment = this.#_49BipA5dq9eoH8LX8xdsVumveTca_attachment; if ("attachments" in values && values.attachments != null) if (Array.isArray(values.attachments) && values.attachments.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof PropertyValue || v instanceof URL)) clone.#_49BipA5dq9eoH8LX8xdsVumveTca_attachment = values.attachments; else throw new TypeError("The attachments must be an array of type Object | Link | PropertyValue | URL."); clone.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = this.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo; if ("attribution" in values && values.attribution != null) if (values.attribution instanceof Application || values.attribution instanceof Group || values.attribution instanceof Organization || values.attribution instanceof Person || values.attribution instanceof Service || values.attribution instanceof URL) clone.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = [values.attribution]; else throw new TypeError("The attribution must be of type Application | Group | Organization | Person | Service | URL."); if ("attributions" in values && values.attributions != null) { if ("attribution" in values && values.attribution != null) throw new TypeError("Cannot update both attribution and attributions at the same time."); if (Array.isArray(values.attributions) && values.attributions.every((v) => v instanceof Application || v instanceof Group || v instanceof Organization || v instanceof Person || v instanceof Service || v instanceof URL)) clone.#_42CGqJ94zgQ3ZBbfHwD8Hrr2L5Py_attributedTo = values.attributions; else throw new TypeError("The attributions must be an array of type Application | Group | Organization | Person | Service | URL."); } clone.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = this.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience; if ("audience" in values && values.audience != null) if (values.audience instanceof Object$1 || values.audience instanceof URL) clone.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = [values.audience]; else throw new TypeError("The audience must be of type Object | URL."); if ("audiences" in values && values.audiences != null) { if ("audience" in values && values.audience != null) throw new TypeError("Cannot update both audience and audiences at the same time."); if (Array.isArray(values.audiences) && values.audiences.every((v) => v instanceof Object$1 || v instanceof URL)) clone.#_3ocC3VVi88cEd5sPWL8djkZsvTN6_audience = values.audiences; else throw new TypeError("The audiences must be an array of type Object | URL."); } clone.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = this.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content; if ("content" in values && values.content != null) if (typeof values.content === "string" || values.content instanceof LanguageString) clone.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = [values.content]; else throw new TypeError("The content must be of type string | LanguageString."); if ("contents" in values && values.contents != null) { if ("content" in values && values.content != null) throw new TypeError("Cannot update both content and contents at the same time."); if (Array.isArray(values.contents) && values.contents.every((v) => typeof v === "string" || v instanceof LanguageString)) clone.#_4HuuRSdSrXq8Jj2J9gcdYfoCzeuz_content = values.contents; else throw new TypeError("The contents must be an array of type string | LanguageString."); } clone.#_3mhZzGXSpQ431mBSz2kvych22v4e_context = this.#_3mhZzGXSpQ431mBSz2kvych22v4e_context; if ("contexts" in values && values.contexts != null) if (Array.isArray(values.contexts) && values.contexts.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) clone.#_3mhZzGXSpQ431mBSz2kvych22v4e_context = values.contexts; else throw new TypeError("The contexts must be an array of type Object | Link | URL."); clone.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = this.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name; if ("name" in values && values.name != null) if (typeof values.name === "string" || values.name instanceof LanguageString) clone.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = [values.name]; else throw new TypeError("The name must be of type string | LanguageString."); if ("names" in values && values.names != null) { if ("name" in values && values.name != null) throw new TypeError("Cannot update both name and names at the same time."); if (Array.isArray(values.names) && values.names.every((v) => typeof v === "string" || v instanceof LanguageString)) clone.#_4ZHbBuK7PrsvGgrjM8wgc6KMWjav_name = values.names; else throw new TypeError("The names must be an array of type string | LanguageString."); } clone.#_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime = this.#_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime; if ("endTime" in values && values.endTime != null) if (values.endTime instanceof Temporal.Instant) clone.#_219RwDanjScTv5tYCjwGZVCM7KZ9_endTime = [values.endTime]; else throw new TypeError("The endTime must be of type Temporal.Instant."); clone.#_86xFhmgBapoMvYqjbjRuDPayTrS_generator = this.#_86xFhmgBapoMvYqjbjRuDPayTrS_generator; if ("generators" in values && values.generators != null) if (Array.isArray(values.generators) && values.generators.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) clone.#_86xFhmgBapoMvYqjbjRuDPayTrS_generator = values.generators; else throw new TypeError("The generators must be an array of type Object | Link | URL."); clone.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = this.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon; if ("icon" in values && values.icon != null) if (values.icon instanceof Image || values.icon instanceof URL) clone.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = [values.icon]; else throw new TypeError("The icon must be of type Image | URL."); if ("icons" in values && values.icons != null) { if ("icon" in values && values.icon != null) throw new TypeError("Cannot update both icon and icons at the same time."); if (Array.isArray(values.icons) && values.icons.every((v) => v instanceof Image || v instanceof URL)) clone.#_33CjRLy5ujtsUrwRSCrsggvGdKuR_icon = values.icons; else throw new TypeError("The icons must be an array of type Image | URL."); } clone.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = this.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image; if ("image" in values && values.image != null) if (values.image instanceof Image || values.image instanceof URL) clone.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = [values.image]; else throw new TypeError("The image must be of type Image | URL."); if ("images" in values && values.images != null) { if ("image" in values && values.image != null) throw new TypeError("Cannot update both image and images at the same time."); if (Array.isArray(values.images) && values.images.every((v) => v instanceof Image || v instanceof URL)) clone.#_3dXrUdkARxwyJLtJcYi1AJ92H41U_image = values.images; else throw new TypeError("The images must be an array of type Image | URL."); } clone.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = this.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo; if ("replyTarget" in values && values.replyTarget != null) if (values.replyTarget instanceof Object$1 || values.replyTarget instanceof Link || values.replyTarget instanceof URL) clone.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = [values.replyTarget]; else throw new TypeError("The replyTarget must be of type Object | Link | URL."); if ("replyTargets" in values && values.replyTargets != null) { if ("replyTarget" in values && values.replyTarget != null) throw new TypeError("Cannot update both replyTarget and replyTargets at the same time."); if (Array.isArray(values.replyTargets) && values.replyTargets.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) clone.#_3fpbDrvZgf3Kq1a5V9aByFn8kx3s_inReplyTo = values.replyTargets; else throw new TypeError("The replyTargets must be an array of type Object | Link | URL."); } clone.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = this.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location; if ("location" in values && values.location != null) if (values.location instanceof Object$1 || values.location instanceof Link || values.location instanceof URL) clone.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = [values.location]; else throw new TypeError("The location must be of type Object | Link | URL."); if ("locations" in values && values.locations != null) { if ("location" in values && values.location != null) throw new TypeError("Cannot update both location and locations at the same time."); if (Array.isArray(values.locations) && values.locations.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) clone.#_31k5MUZJsnsPNg8dQQJieWaXTFnR_location = values.locations; else throw new TypeError("The locations must be an array of type Object | Link | URL."); } clone.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview = this.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview; if ("preview" in values && values.preview != null) if (values.preview instanceof Link || values.preview instanceof Object$1 || values.preview instanceof URL) clone.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview = [values.preview]; else throw new TypeError("The preview must be of type Link | Object | URL."); if ("previews" in values && values.previews != null) { if ("preview" in values && values.preview != null) throw new TypeError("Cannot update both preview and previews at the same time."); if (Array.isArray(values.previews) && values.previews.every((v) => v instanceof Link || v instanceof Object$1 || v instanceof URL)) clone.#_gCVTegXxWWCw6wWRxa1QF65zusg_preview = values.previews; else throw new TypeError("The previews must be an array of type Link | Object | URL."); } clone.#_5e258TDXtuhaFRPZiGoDfEpjdMr_published = this.#_5e258TDXtuhaFRPZiGoDfEpjdMr_published; if ("published" in values && values.published != null) if (values.published instanceof Temporal.Instant) clone.#_5e258TDXtuhaFRPZiGoDfEpjdMr_published = [values.published]; else throw new TypeError("The published must be of type Temporal.Instant."); clone.#_7UpwM3JWcXhADcscukEehBorf6k_replies = this.#_7UpwM3JWcXhADcscukEehBorf6k_replies; if ("replies" in values && values.replies != null) if (values.replies instanceof Collection || values.replies instanceof URL) clone.#_7UpwM3JWcXhADcscukEehBorf6k_replies = [values.replies]; else throw new TypeError("The replies must be of type Collection | URL."); clone.#_3kAfck9PcEYt2L7xug5y99YPbANs_shares = this.#_3kAfck9PcEYt2L7xug5y99YPbANs_shares; if ("shares" in values && values.shares != null) if (values.shares instanceof Collection || values.shares instanceof URL) clone.#_3kAfck9PcEYt2L7xug5y99YPbANs_shares = [values.shares]; else throw new TypeError("The shares must be of type Collection | URL."); clone.#_S3ceDnpMdzoTRCccB9FkJWrEzYW_likes = this.#_S3ceDnpMdzoTRCccB9FkJWrEzYW_likes; if ("likes" in values && values.likes != null) if (values.likes instanceof Collection || values.likes instanceof URL) clone.#_S3ceDnpMdzoTRCccB9FkJWrEzYW_likes = [values.likes]; else throw new TypeError("The likes must be of type Collection | URL."); clone.#_kMatyyNAuxoTD8GQMBfA5ogThMR_emojiReactions = this.#_kMatyyNAuxoTD8GQMBfA5ogThMR_emojiReactions; if ("emojiReactions" in values && values.emojiReactions != null) if (values.emojiReactions instanceof Collection || values.emojiReactions instanceof URL) clone.#_kMatyyNAuxoTD8GQMBfA5ogThMR_emojiReactions = [values.emojiReactions]; else throw new TypeError("The emojiReactions must be of type Collection | URL."); clone.#_2w3Jmue4up8iVDUA51WZqomEF438_startTime = this.#_2w3Jmue4up8iVDUA51WZqomEF438_startTime; if ("startTime" in values && values.startTime != null) if (values.startTime instanceof Temporal.Instant) clone.#_2w3Jmue4up8iVDUA51WZqomEF438_startTime = [values.startTime]; else throw new TypeError("The startTime must be of type Temporal.Instant."); clone.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = this.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary; if ("summary" in values && values.summary != null) if (typeof values.summary === "string" || values.summary instanceof LanguageString) clone.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = [values.summary]; else throw new TypeError("The summary must be of type string | LanguageString."); if ("summaries" in values && values.summaries != null) { if ("summary" in values && values.summary != null) throw new TypeError("Cannot update both summary and summaries at the same time."); if (Array.isArray(values.summaries) && values.summaries.every((v) => typeof v === "string" || v instanceof LanguageString)) clone.#_4LqirZspQbFWWQEbFcXAxm7tTDN1_summary = values.summaries; else throw new TypeError("The summaries must be an array of type string | LanguageString."); } clone.#_5chuqj6s95p5gg2sk1HntGfarRf_tag = this.#_5chuqj6s95p5gg2sk1HntGfarRf_tag; if ("tags" in values && values.tags != null) if (Array.isArray(values.tags) && values.tags.every((v) => v instanceof Object$1 || v instanceof Link || v instanceof URL)) clone.#_5chuqj6s95p5gg2sk1HntGfarRf_tag = values.tags; else throw new TypeError("The tags must be an array of type Object | Link | URL."); clone.#_385aB7ySixcf5Un6z3VsWmThgCzQ_updated = this.#_385aB7ySixcf5Un6z3VsWmThgCzQ_updated; if ("updated" in values && values.updated != null) if (values.updated instanceof Temporal.Instant) clone.#_385aB7ySixcf5Un6z3VsWmThgCzQ_updated = [values.updated]; else throw new TypeError("The updated must be of type Temporal.Instant."); clone.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = this.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url; if ("url" in values && values.url != null) if (values.url instanceof URL || values.url instanceof Link) clone.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = [values.url]; else throw new TypeError("The url must be of type URL | Link."); if ("urls" in values && values.urls != null) { if ("url" in values && values.url != null) throw new TypeError("Cannot update both url and urls at the same time."); if (Array.isArray(values.urls) && values.urls.every((v) => v instanceof URL || v instanceof Link)) clone.#_2oPEH9MQ3aj8JVwyYuWkqoVwV865_url = values.urls; else throw new TypeError("The urls must be an array of type URL | Link."); } clone.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = this.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to; if ("to" in values && values.to != null) if (values.to instanceof Object$1 || values.to instanceof URL) clone.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = [values.to]; else throw new TypeError("The to must be of type Object | URL."); if ("tos" in values && values.tos != null) { if ("to" in values && values.to != null) throw new TypeError("Cannot update both to and tos at the same time."); if (Array.isArray(values.tos) && values.tos.every((v) => v instanceof Object$1 || v instanceof URL)) clone.#_3hFbw7DTpHhq3cvVhkY8njhcsXbd_to = values.tos; else throw new TypeError("The tos must be an array of type Object | URL."); } clone.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = this.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto; if ("bto" in values && values.bto != null) if (values.bto instanceof Object$1 || values.bto instanceof URL) clone.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = [values.bto]; else throw new TypeError("The bto must be of type Object | URL."); if ("btos" in values && values.btos != null) { if ("bto" in values && values.bto != null) throw new TypeError("Cannot update both bto and btos at the same time."); if (Array.isArray(values.btos) && values.btos.every((v) => v instanceof Object$1 || v instanceof URL)) clone.#_aLZupjwL8XB7tzdLgCMXdjZ6qej_bto = values.btos; else throw new TypeError("The btos must be an array of type Object | URL."); } clone.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = this.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc; if ("cc" in values && values.cc != null) if (values.cc instanceof Object$1 || values.cc instanceof URL) clone.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = [values.cc]; else throw new TypeError("The cc must be of type Object | URL."); if ("ccs" in values && values.ccs != null) { if ("cc" in values && values.cc != null) throw new TypeError("Cannot update both cc and ccs at the same time."); if (Array.isArray(values.ccs) && values.ccs.every((v) => v instanceof Object$1 || v instanceof URL)) clone.#_42a1SvBs24QSLzKcfjCyNTjW5a1g_cc = values.ccs; else throw new TypeError("The ccs must be an array of type Object | URL."); } clone.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = this.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc; if ("bcc" in values && values.bcc != null) if (values.bcc instanceof Object$1 || values.bcc instanceof URL) clone.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = [values.bcc]; else throw new TypeError("The bcc must be of type Object | URL."); if ("bccs" in values && values.bccs != null) { if ("bcc" in values && values.bcc != null) throw new TypeError("Cannot update both bcc and bccs at the same time."); if (Array.isArray(values.bccs) && values.bccs.every((v) => v instanceof Object$1 || v instanceof URL)) clone.#_3qvegKUB8YLgTXRpEf8E6JZSkz2H_bcc = values.bccs; else throw new TypeError("The bccs must be an array of type Object | URL."); } clone.#_3BLrzmscsjHCw8TF5BHRW9WkPnX8_mediaType = this.#_3BLrzmscsjHCw8TF5BHRW9WkPnX8_mediaType; if ("mediaType" in values && values.mediaType != null) if (typeof values.mediaType === "string") clone.#_3BLrzmscsjHCw8TF5BHRW9WkP