@cbortech/cbor 0.26.3 → 0.26.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["#defaults","#merge"],"sources":["../src/extensions/b32.ts","../src/extensions/same.ts","../src/cbor.ts"],"sourcesContent":["import type { CborExtension } from './types';\nimport { CborByteString } from '../ast/CborByteString';\nimport { stripComments } from '../utils/strip-comments';\n\nconst B32_ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst H32_ALPHA = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\n\nfunction stripBase32Padding(str: string): string {\n let end = str.length;\n while (end > 0 && str.charCodeAt(end - 1) === 0x3d) end--;\n return str.slice(0, end);\n}\n\nfunction base32Decode(\n str: string,\n alpha: string,\n onError?: (msg: string) => void\n): Uint8Array {\n // Padding is optional; strip it before decoding.\n const s = stripBase32Padding(str).toUpperCase();\n // RFC 4648 §6: valid unpadded lengths mod 8 are 0, 2, 4, 5, 7.\n // Lengths 1, 3, 6 can never result from any valid byte sequence.\n const rem = s.length % 8;\n if (rem === 1 || rem === 3 || rem === 6)\n throw new SyntaxError(`invalid base32 length: ${s.length} characters`);\n const lookup = new Uint8Array(128).fill(0xff);\n for (let i = 0; i < alpha.length; i++) lookup[alpha.charCodeAt(i)] = i;\n const out = new Uint8Array(Math.floor((s.length * 5) / 8));\n let buf = 0,\n bufBits = 0,\n outIdx = 0;\n for (const ch of s) {\n const code = ch.charCodeAt(0);\n const val = code < 128 ? lookup[code] : 0xff;\n if (val === 0xff)\n throw new SyntaxError(\n `invalid character in byte string: ${JSON.stringify(ch)}`\n );\n buf = (buf << 5) | val;\n bufBits += 5;\n if (bufBits >= 8) {\n bufBits -= 8;\n out[outIdx++] = (buf >> bufBits) & 0xff;\n }\n }\n // RFC 4648 §3.5: trailing bits in the final quantum must be zero.\n if (bufBits > 0 && (buf & ((1 << bufBits) - 1)) !== 0) {\n const msg = 'non-zero trailing bits in base32 input';\n if (onError) onError(msg);\n else throw new SyntaxError(msg);\n }\n return out;\n}\n\n/** RFC 4648 §6 Base32 (A–Z 2–7) app-string extension. */\nexport const b32: CborExtension = {\n appStringPrefixes: ['b32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), B32_ALPHA, onError),\n {\n ednEncoding: 'base32',\n }\n );\n },\n};\n\n/** RFC 4648 §7 Base32Hex (0–9 A–V) app-string extension. */\nexport const h32: CborExtension = {\n appStringPrefixes: ['h32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), H32_ALPHA, onError),\n {\n ednEncoding: 'base32hex',\n }\n );\n },\n};\n","/**\n * `same<<expr, expr, ...>>` app-sequence extension.\n *\n * Evaluates every item in the sequence to CBOR bytes and asserts that all\n * produce identical bytes. Returns the first item if all match.\n *\n * In strict mode a mismatch throws a `SyntaxError`. In lenient mode\n * (`strict: false`) a mismatch emits a `ParseWarning` and returns the first\n * item so parsing can continue.\n *\n * `same<<x>>` (single item) is a no-op assertion that always passes.\n *\n * The parsed result is wrapped in `CborAppSeqResult` so that `toCDN()` round-trips\n * the original `same<<...>>` notation. `toCBOR()` and `toJS()` delegate\n * transparently to the inner item; `appStrings: false` produces the resolved value.\n * The result is not directly `instanceof` the inner item's class.\n *\n * This extension is a testing/validation construct from the cabo/edn-abnf\n * corpus and is NOT part of draft-ietf-cbor-edn-literals. It is not included\n * in the default extension set. Add it explicitly:\n *\n * @example\n * import { same } from '@cbortech/cbor';\n * parseCDN(\"same<<b64'AA',h'00'>>\", { extensions: [same] }); // h'00'\n */\n\nimport type { CborExtension } from './types';\nimport type { CborItem } from '../ast/CborItem';\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/**\n * Extension object for `same<<...>>`.\n * Pass to `parseCDN(..., { extensions: [same] })`.\n */\nexport const same: CborExtension = {\n appStringPrefixes: ['same'],\n preserveAppSeqSource: true,\n\n parseAppSequence(\n _prefix: string,\n items: CborItem[],\n onError?: (msg: string) => void\n ): CborItem {\n if (items.length === 0)\n throw new SyntaxError(`same<<...>> requires at least one item`);\n const first = items[0]!;\n const firstCbor = first.toCBOR();\n for (let i = 1; i < items.length; i++) {\n const otherCbor = items[i]!.toCBOR();\n if (!bytesEqual(firstCbor, otherCbor)) {\n const msg = `same<<...>>: item ${i} produces different CBOR bytes than item 0`;\n if (onError)\n onError(msg); // lenient: warn + return first item\n else throw new SyntaxError(msg);\n }\n }\n return first;\n },\n};\n\nexport default same;\n","import type { CborItem } from './ast/CborItem';\nimport type {\n CBOROptions,\n FromCBOROptions,\n FromCBORSeqOptions,\n FromCDNOptions,\n FromCDNSeqOptions,\n FromHexDumpOptions,\n FromJSOptions,\n ParseWarning,\n ToCBOROptions,\n ToCDNOptions,\n ToHexDumpOptions,\n ToJSOptions,\n} from './types';\nimport { CBOR_OMIT } from './types';\nimport { decodeCBOR } from './cbor/decoder';\nimport { parseCDN } from './cdn/parser';\nimport { CdnSyntaxError } from './cdn/errors';\nimport { dt_as_Date as _dt_as_Date } from './extensions/dt';\nimport { fromJS as _fromJS, _applyReplacer } from './js/fromJS';\nimport { MapEntries as _MapEntries } from './mapEntries';\nimport { Simple as _Simple } from './simple';\nimport { CBOR_TAG, Tag as _Tag } from './tag';\n\n/**\n * Main facade class.\n *\n * Provides factory methods for constructing AST nodes from the three\n * supported input formats, and shortcut methods that mirror the\n * `JSON.parse` / `JSON.stringify` API.\n *\n * @example\n * // CBOR binary → AST → CBOR binary\n * const ast = CBOR.fromCBOR(bytes);\n * const reencoded = ast.toCBOR();\n *\n * @example\n * // JS value → CBOR binary (shortcut)\n * const bytes = CBOR.encode({ hello: 'world' });\n *\n * @example\n * // CBOR binary → JS value (shortcut)\n * const value = CBOR.decode(bytes);\n */\nexport class CBOR {\n /**\n * Sentinel returned from a replacer or reviver to omit the key/element from\n * the output. Use this instead of `undefined` when `undefinedOmits` is\n * `false` (the default) and you need to drop a specific entry.\n */\n static readonly OMIT: typeof CBOR_OMIT = CBOR_OMIT;\n\n /** Unique symbol used to attach a CBOR tag number to a JS value. */\n static readonly TAG: typeof CBOR_TAG = CBOR_TAG;\n\n /** Namespace for CBOR tag annotation utilities. */\n static readonly Tag: typeof _Tag = _Tag;\n\n /** Wrapper for CBOR simple values other than false/true/null/undefined. */\n static readonly Simple: typeof _Simple = _Simple;\n\n /** Array subclass used to preserve CBOR map entries, including duplicates. */\n static readonly MapEntries: typeof _MapEntries = _MapEntries;\n\n /** Extension that maps CDN dt/DT values to JavaScript Date objects. */\n static readonly dt_as_Date: typeof _dt_as_Date = _dt_as_Date;\n\n // ─── Instance API ───────────────────────────────────────────────────────────\n\n readonly #defaults: CBOROptions;\n\n /**\n * Create a reusable instance with default options applied to every method call.\n * Per-call options always override these defaults.\n *\n * @example\n * const cbor = new CBOR({ extensions: [CBOR.dt_as_Date] });\n * const obj = cbor.parse('{ \"dt\": DT\\'2024-01-01T00:00:00Z\\' }');\n * const text = cbor.stringify(obj);\n */\n constructor(defaults?: CBOROptions) {\n this.#defaults = defaults ?? {};\n }\n\n #merge<T extends object>(perCall?: T): CBOROptions & T {\n return { ...this.#defaults, ...(perCall ?? {}) } as CBOROptions & T;\n }\n\n fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n const node = CBOR.fromCBOR(input, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromCDN(text: string, options?: FromCDNOptions): CborItem {\n const node = CBOR.fromCDN(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n /** @deprecated Use `fromCDN()` instead. */\n fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return this.fromCDN(text, options);\n }\n\n fromJS(value: unknown, options?: FromJSOptions): CborItem {\n const node = CBOR.fromJS(value, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const node = CBOR.fromHexDump(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromCBORSeq(input, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromCDNSeq(text: string, options?: FromCDNSeqOptions): Generator<CborItem> {\n for (const item of CBOR.fromCDNSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromHexDumpSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.decode(input, this.#merge(options));\n }\n\n *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.decodeSeq(input, this.#merge(options));\n }\n\n *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.parseSeq(text, this.#merge(options));\n }\n\n encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array {\n return CBOR.encode(value, this.#merge(options));\n }\n\n compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.compile(text, this.#merge(options));\n }\n\n decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return CBOR.decompile(input, this.#merge(options));\n }\n\n toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return CBOR.toHex(input, this.#merge(options));\n }\n\n fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromHex(text, this.#merge(options));\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return this.cborToCdn(input, options);\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n const merged = this.#merge(options);\n const node = CBOR.fromCBOR(input, merged);\n node._defaults = this.#defaults;\n return node.toCDN(merged);\n }\n\n /** @deprecated Use `compile()` instead. */\n cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return this.cdnToCbor(text, options);\n }\n\n /** @deprecated Use `compile()` instead. */\n cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n const merged = this.#merge(options);\n return CBOR.fromCDN(text, merged).toCBOR(merged);\n }\n\n parse(text: string): unknown;\n parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n const merged = this.#merge<ToJSOptions>({ reviver: arg2 });\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n const merged = this.#merge(arg2);\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n\n stringify(value: unknown): string;\n stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;\n stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const opts: FromJSOptions & ToCDNOptions = {\n ...(this.#defaults as FromJSOptions & ToCDNOptions),\n };\n if (arg2 === null) {\n opts.replacer = undefined;\n } else if (typeof arg2 === 'function' || Array.isArray(arg2)) {\n opts.replacer = arg2;\n }\n if (arg3 !== undefined) opts.indent = resolveSpace(arg3);\n return CBOR.stringify(value, opts);\n }\n return CBOR.stringify(value, this.#merge(arg2 ?? undefined));\n }\n\n format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.format(text, this.#merge(options));\n }\n\n // ─── Factory methods ────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data into an AST node. */\n static fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n return decodeCBOR(input, options);\n }\n\n /** Parse a CDN text string into an AST node. */\n static fromCDN(text: string, options?: FromCDNOptions): CborItem {\n return parseCDN(text, options);\n }\n\n /**\n * Parse a CDN text string into an AST node.\n *\n * @deprecated Use `fromCDN()` instead.\n */\n static fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return CBOR.fromCDN(text, options);\n }\n\n /** アノテーション付き hex dump テキストから CBOR Sequence を item ごとにデコードするジェネレータ。 */\n static *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n yield* CBOR.fromCBORSeq(new Uint8Array(bytes), options);\n }\n\n /** CBOR Sequence (RFC 8742) を item ごとにデコードするジェネレータ。 */\n static *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n const bytes =\n input instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' &&\n input instanceof SharedArrayBuffer)\n ? new Uint8Array(input)\n : new Uint8Array(\n (input as ArrayBufferView).buffer,\n (input as ArrayBufferView).byteOffset,\n (input as ArrayBufferView).byteLength\n );\n let offset = 0;\n while (offset < bytes.byteLength) {\n const item = decodeCBOR(bytes, {\n ...options,\n offset,\n allowTrailing: true,\n });\n yield item;\n offset = item.end!;\n }\n }\n\n /**\n * CDN テキストの複数 item を 1 つずつパースするジェネレータ。\n *\n * `preserveComments` が有効な場合、item 間のコメントは次の item の\n * leading コメントとして、item と同じ行にあるコメントはその item の\n * trailing コメントとして付与される。最後の item の後の行にだけ\n * コメントが残る場合、そのコメントはどの item にも属さず破棄される。\n */\n static *fromCDNSeq(\n text: string,\n options?: FromCDNSeqOptions\n ): Generator<CborItem> {\n const preserve = !!options?.preserveComments;\n let offset = 0;\n let isFirst = true;\n while (true) {\n const {\n offset: next,\n hadSeparator,\n commaOffset,\n } = skipCDNSeparator(\n text,\n offset,\n options,\n preserve ? (isFirst ? 'all' : 'after-newline') : 'none'\n );\n // Leading comma: comma before the first item (including comma-only input).\n // Checked before the EOF break so that \",\" alone is also caught.\n // Trailing comma is valid per ABNF SOC = S [\",\" S] and is silently accepted.\n if (isFirst && commaOffset >= 0) {\n const msg = 'leading comma in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, commaOffset, options);\n }\n if (next >= text.length) break;\n // Stopped at a comment that should lead the next item: make sure an\n // item actually follows. If only comments remain, we are done (the\n // remaining comments belong to no item and are dropped, matching the\n // behaviour of `preserveComments: false`).\n if (preserve && isCDNCommentStart(text, next)) {\n const lookahead = skipCDNSeparator(text, next, options);\n if (lookahead.offset >= text.length) break;\n }\n if (!isFirst && !hadSeparator) {\n const msg =\n 'CDN sequence items must be separated by whitespace, comma, or comment';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, next, options);\n }\n offset = next;\n let item: CborItem;\n try {\n // _skipRS: true causes the tokenizer to treat RS (U+001E, RFC 7464) as\n // whitespace, preventing it from corrupting string-literal contents via\n // a global text replacement.\n item = parseCDN(text, {\n ...options,\n offset,\n allowTrailing: true,\n _skipRS: true,\n } as FromCDNOptions);\n } catch (e) {\n if (options?.strict !== false) throw e;\n emitCDNSeqWarning(\n e instanceof Error ? e.message : String(e),\n offset,\n options,\n true,\n e instanceof CdnSyntaxError ? e : undefined\n );\n break;\n }\n yield item;\n offset = item.end!;\n isFirst = false;\n }\n }\n\n /** Convert a JavaScript value into an AST node. */\n static fromJS(value: unknown, options?: FromJSOptions): CborItem {\n return _fromJS(value, options);\n }\n\n /**\n * Parse an annotated hex dump (as produced by {@link CborItem#toHexDump})\n * into an AST node.\n *\n * Each line is expected to have the form:\n * `[whitespace] HH [HH …] -- comment`\n * `[whitespace] HH [HH …] # comment`\n * `[whitespace] HH [HH …] // comment`\n * Block comments may also be written as `/ comment /` or `/* comment *\\/`.\n * Lines with no hex content before the comment marker are ignored.\n */\n static fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n return decodeCBOR(new Uint8Array(bytes), options);\n }\n\n // ─── Shortcut API ───────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data directly to a JavaScript value. */\n static decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.fromCBOR(input, options).toJS(options);\n }\n\n /** Decode a CBOR Sequence (RFC 8742), yielding each item as a JavaScript value. */\n static *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCBORSeq(input, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Parse a CDN Sequence text string, yielding each item as a JavaScript value. */\n static *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCDNSeq(text, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Encode a JavaScript value directly to CBOR binary data. */\n static encode(\n value: unknown,\n options?: FromJSOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromJS(value, options).toCBOR(options);\n }\n\n /**\n * Compile a CDN text string to CBOR binary data.\n * Multi-item CDN Sequences produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromCDNSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Decompile CBOR binary data to a CDN text string.\n * CBOR Sequences (RFC 8742) produce multi-item CDN output, with items separated by newlines.\n */\n static decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toCDN(options))\n .join('\\n');\n }\n\n /**\n * Convert CBOR binary data to an annotated hex dump string.\n * CBOR Sequences (RFC 8742) produce one dump per item, separated by newlines.\n */\n static toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toHexDump(options))\n .join('\\n');\n }\n\n /**\n * Parse an annotated hex dump string to CBOR binary data.\n * Multi-item dumps produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromHexDumpSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Convert CBOR binary data directly to a CDN text string.\n *\n * @deprecated Use `CBOR.decompile()` instead.\n */\n static cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /** @deprecated Use `CBOR.decompile()` instead. */\n static cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /**\n * Convert a CDN text string directly to CBOR binary data.\n *\n * @deprecated Use `CBOR.compile()` instead.\n */\n static cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /** @deprecated Use `CBOR.compile()` instead. */\n static cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /**\n * Parse a CDN text string directly to a JavaScript value.\n *\n * Accepts either a JSON-compatible `reviver` function as the second argument,\n * or a plain options object (existing API).\n *\n * When a `reviver` is supplied it is applied bottom-up after the CDN text has\n * been parsed and converted to a JS value, matching the semantics of\n * `JSON.parse(text, reviver)`.\n *\n * Note: CBOR-specific value types such as `bigint` are passed to the reviver\n * as-is; the reviver is responsible for handling them.\n */\n static parse(text: string): unknown;\n static parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n static parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n return CBOR.fromCDN(text).toJS({ reviver: arg2 });\n }\n return CBOR.fromCDN(text, arg2).toJS(arg2);\n }\n\n /**\n * Serialize a JavaScript value directly to a CDN text string.\n *\n * Accepts either JSON-compatible `replacer` + `space` arguments, or a plain\n * options object (existing API).\n *\n * - `replacer` may be a function (transforms each key/value before encoding)\n * or an array of strings/numbers (allowlist of object keys to include).\n * Pass `null` to skip filtering.\n * - `space` controls indentation, mapping to `ToCDNOptions.indent`.\n * Numbers are clamped to `[0, 10]`; strings are truncated to 10 characters.\n */\n static stringify(value: unknown): string;\n static stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n static stringify(\n value: unknown,\n options: FromJSOptions & ToCDNOptions\n ): string;\n static stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const replacer =\n typeof arg2 === 'function' || Array.isArray(arg2) ? arg2 : undefined;\n const indent = resolveSpace(arg3);\n if (replacer) {\n // Mirror JSON.stringify: if the replacer drops the root, return undefined.\n const replaced = _applyReplacer(value, replacer);\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n return _fromJS(replaced).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n return _fromJS(value).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n // Options form: also mirror JSON.stringify root-drop semantics.\n const opts = arg2 as (FromJSOptions & ToCDNOptions) | undefined;\n if (opts?.replacer) {\n const replaced = _applyReplacer(\n value,\n opts.replacer,\n opts.extensions,\n opts.undefinedOmits,\n opts.builtinExtensions\n );\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n const { replacer: _r, ...restFromJS } = opts;\n return _fromJS(\n replaced,\n Object.keys(restFromJS).length > 0\n ? (restFromJS as FromJSOptions)\n : undefined\n ).toCDN(opts);\n }\n return _fromJS(value, opts as FromJSOptions | undefined).toCDN(opts);\n }\n\n /** Normalize a CDN text string by parsing and re-serializing it. */\n static format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.fromCDN(text, options).toCDN(options);\n }\n}\n\nfunction stripHexDumpComments(text: string): string {\n let out = '';\n let i = 0;\n\n while (i < text.length) {\n const ch = text[i];\n const next = text[i + 1] ?? '';\n\n if (ch === '-' && next === '-') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '—') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '#') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '/') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '*') {\n const end = text.indexOf('*/', i + 2);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 2));\n i = end + 2;\n continue;\n }\n\n if (ch === '/') {\n const end = text.indexOf('/', i + 1);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 1));\n i = end + 1;\n continue;\n }\n\n out += ch;\n i++;\n }\n\n return out;\n}\n\nfunction skipLineComment(text: string, start: number): number {\n const end = text.indexOf('\\n', start);\n return end < 0 ? text.length : end;\n}\n\nfunction whitespaceLike(text: string): string {\n return text.replace(/[^\\r\\n]/g, ' ');\n}\n\n// ─── Module-scope helper ─────────────────────────────────────────────────────\n\nfunction emitCDNSeqWarning(\n msg: string,\n fallbackOffset: number,\n options: FromCDNSeqOptions | undefined,\n fatal?: boolean,\n cause?: CdnSyntaxError\n): void {\n const offset = cause?.offset ?? fallbackOffset;\n const w: ParseWarning = { message: msg, offset };\n if (fatal) w.fatal = true;\n if (cause?.offset !== undefined) {\n w.line = cause.line;\n w.column = cause.column;\n w.endOffset = cause.endOffset;\n }\n if (options?.onWarning) options.onWarning(w);\n else if (!options?.silent)\n console.warn(`CDN sequence warning at offset ${offset}: ${msg}`);\n}\n\n/** Whether `text[i]` starts a CDN comment (`#`, `//`, `/* … *\\/`, or `/ … /`). */\nfunction isCDNCommentStart(text: string, i: number): boolean {\n const ch = text[i];\n return ch === '#' || ch === '/';\n}\n\n/**\n * CDN sequence の item 間にある空白・コメント・省略可能なカンマを読み飛ばし、\n * 次の item が始まる文字位置と、何らかの separator が存在したかどうかを返す。\n * 未終端のブロックコメントは strict モードでは throw し、\n * strict: false の場合は警告を emit して末尾まで読み飛ばす。\n *\n * `stopAtComments` は `preserveComments` 有効時にコメントを次の item の\n * leading コメントとして残すためのモード:\n * - `'none'`: コメントも読み飛ばす(従来動作)\n * - `'all'`: 最初のコメントで停止する(先頭 item 用)\n * - `'after-newline'`: 改行より後のコメントで停止する。直前 item と同じ行の\n * コメントはその item の trailing コメントとして既に付与されているため読み飛ばす。\n */\nfunction skipCDNSeparator(\n text: string,\n from: number,\n options: FromCDNSeqOptions | undefined,\n stopAtComments: 'none' | 'after-newline' | 'all' = 'none'\n): { offset: number; hadSeparator: boolean; commaOffset: number } {\n let i = from;\n let hadSeparator = false;\n let seenComma = false;\n let seenNewline = false;\n let commaOffset = -1;\n const stopHere = (): boolean =>\n stopAtComments === 'all' ||\n (stopAtComments === 'after-newline' && seenNewline);\n while (i < text.length) {\n const ch = text[i];\n if (ch === ' ' || ch === '\\t' || ch === '\\r' || ch === '\\x1e') {\n hadSeparator = true;\n i++;\n continue;\n }\n if (ch === '\\n') {\n hadSeparator = true;\n seenNewline = true;\n i++;\n continue;\n }\n if (ch === '#') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 1);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 2);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '*') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('*/', i + 2);\n if (end < 0) {\n const msg = 'unterminated /* comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 2;\n }\n continue;\n }\n if (ch === '/' && text[i + 1] !== '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('/', i + 1);\n if (end < 0) {\n const msg = 'unterminated / comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 1;\n }\n continue;\n }\n if (ch === ',' && !seenComma) {\n hadSeparator = true;\n seenComma = true;\n commaOffset = i;\n i++;\n continue;\n }\n break;\n }\n return { offset: i, hadSeparator, commaOffset };\n}\n\n/** Map JSON.stringify `space` argument to ToCDNOptions.indent. */\nfunction resolveSpace(\n space: string | number | undefined\n): string | number | undefined {\n if (typeof space === 'number') {\n const n = Math.floor(Math.min(10, Math.max(0, space)));\n return n === 0 ? undefined : n;\n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GAEZ;EACF;EACA,IAAI,MAAO,OAAO,EAAK,IAAI,OAAO,KAAK;GAErC,IADA,IAAe,IACX,EAAS,GAAG;GAChB,IAAM,IAAM,EAAK,QAAQ,KAAK,IAAI,CAAC;GACnC,IAAI,IAAM,GAAG;IACX,IAAM,IAAM;IACZ,IAAI,GAAS,WAAW,IAAO,MAAU,YAAY,CAAG;IAExD,AADA,EAAkB,GAAK,GAAG,GAAS,EAAI,GACvC,IAAI,EAAK;GACX,OAEE,AADI,EAAK,MAAM,GAAG,CAAG,CAAC,CAAC,SAAS,IAAI,MAAG,IAAc,KACrD,IAAI,IAAM;GAEZ;EACF;EACA,IAAI,MAAO,OAAO,CAAC,GAAW;GAI5B,AAHA,IAAe,IACf,IAAY,IACZ,IAAc,GACd;GACA;EACF;EACA;CACF;CACA,OAAO;EAAE,QAAQ;EAAG;EAAc;CAAY;AAChD;AAGA,SAAS,EACP,GAC6B;CAC7B,IAAI,OAAO,KAAU,UAAU;EAC7B,IAAM,IAAI,KAAK,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,CAAK,CAAC,CAAC;EACrD,OAAO,MAAM,IAAI,KAAA,IAAY;CAC/B;CACA,IAAI,OAAO,KAAU,UAEnB,OADU,EAAM,MAAM,GAAG,EAClB,KAAK,KAAA;AAGhB"}
1
+ {"version":3,"file":"index.js","names":["#defaults","#merge"],"sources":["../src/extensions/b32.ts","../src/extensions/same.ts","../src/cbor.ts"],"sourcesContent":["import type { CborExtension } from './types';\nimport { CborByteString } from '../ast/CborByteString';\nimport { stripComments } from '../utils/strip-comments';\n\nconst B32_ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst H32_ALPHA = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\n\nfunction stripBase32Padding(str: string): string {\n let end = str.length;\n while (end > 0 && str.charCodeAt(end - 1) === 0x3d) end--;\n return str.slice(0, end);\n}\n\nfunction base32Decode(\n str: string,\n alpha: string,\n onError?: (msg: string) => void\n): Uint8Array {\n // Padding is optional; strip it before decoding.\n const s = stripBase32Padding(str).toUpperCase();\n // RFC 4648 §6: valid unpadded lengths mod 8 are 0, 2, 4, 5, 7.\n // Lengths 1, 3, 6 can never result from any valid byte sequence.\n const rem = s.length % 8;\n if (rem === 1 || rem === 3 || rem === 6)\n throw new SyntaxError(`invalid base32 length: ${s.length} characters`);\n const lookup = new Uint8Array(128).fill(0xff);\n for (let i = 0; i < alpha.length; i++) lookup[alpha.charCodeAt(i)] = i;\n const out = new Uint8Array(Math.floor((s.length * 5) / 8));\n let buf = 0,\n bufBits = 0,\n outIdx = 0;\n for (const ch of s) {\n const code = ch.charCodeAt(0);\n const val = code < 128 ? lookup[code] : 0xff;\n if (val === 0xff)\n throw new SyntaxError(\n `invalid character in byte string: ${JSON.stringify(ch)}`\n );\n buf = (buf << 5) | val;\n bufBits += 5;\n if (bufBits >= 8) {\n bufBits -= 8;\n out[outIdx++] = (buf >> bufBits) & 0xff;\n }\n }\n // RFC 4648 §3.5: trailing bits in the final quantum must be zero.\n if (bufBits > 0 && (buf & ((1 << bufBits) - 1)) !== 0) {\n const msg = 'non-zero trailing bits in base32 input';\n if (onError) onError(msg);\n else throw new SyntaxError(msg);\n }\n return out;\n}\n\n/** RFC 4648 §6 Base32 (A–Z 2–7) app-string extension. */\nexport const b32: CborExtension = {\n appStringPrefixes: ['b32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), B32_ALPHA, onError),\n {\n ednEncoding: 'base32',\n }\n );\n },\n};\n\n/** RFC 4648 §7 Base32Hex (0–9 A–V) app-string extension. */\nexport const h32: CborExtension = {\n appStringPrefixes: ['h32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), H32_ALPHA, onError),\n {\n ednEncoding: 'base32hex',\n }\n );\n },\n};\n","/**\n * `same<<expr, expr, ...>>` app-sequence extension.\n *\n * Evaluates every item in the sequence to CBOR bytes and asserts that all\n * produce identical bytes. Returns the first item if all match.\n *\n * In strict mode a mismatch throws a `SyntaxError`. In lenient mode\n * (`strict: false`) a mismatch emits a `ParseWarning` and returns the first\n * item so parsing can continue.\n *\n * `same<<x>>` (single item) is a no-op assertion that always passes.\n *\n * The parsed result is wrapped in `CborAppSeqResult` so that `toCDN()` round-trips\n * the original `same<<...>>` notation. `toCBOR()` and `toJS()` delegate\n * transparently to the inner item; `appStrings: false` produces the resolved value.\n * The result is not directly `instanceof` the inner item's class.\n *\n * This extension is a testing/validation construct from the cabo/edn-abnf\n * corpus and is NOT part of draft-ietf-cbor-edn-literals. It is not included\n * in the default extension set. Add it explicitly:\n *\n * @example\n * import { same } from '@cbortech/cbor';\n * parseCDN(\"same<<b64'AA',h'00'>>\", { extensions: [same] }); // h'00'\n */\n\nimport type { CborExtension } from './types';\nimport type { CborItem } from '../ast/CborItem';\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/**\n * Extension object for `same<<...>>`.\n * Pass to `parseCDN(..., { extensions: [same] })`.\n */\nexport const same: CborExtension = {\n appStringPrefixes: ['same'],\n preserveAppSeqSource: true,\n\n parseAppSequence(\n _prefix: string,\n items: CborItem[],\n onError?: (msg: string) => void\n ): CborItem {\n if (items.length === 0)\n throw new SyntaxError(`same<<...>> requires at least one item`);\n const first = items[0]!;\n const firstCbor = first.toCBOR();\n for (let i = 1; i < items.length; i++) {\n const otherCbor = items[i]!.toCBOR();\n if (!bytesEqual(firstCbor, otherCbor)) {\n const msg = `same<<...>>: item ${i} produces different CBOR bytes than item 0`;\n if (onError)\n onError(msg); // lenient: warn + return first item\n else throw new SyntaxError(msg);\n }\n }\n return first;\n },\n};\n\nexport default same;\n","import type { CborItem } from './ast/CborItem';\nimport type {\n CBOROptions,\n DecodeWarning,\n FromCBOROptions,\n FromCBORSeqOptions,\n FromCDNOptions,\n FromCDNSeqOptions,\n FromHexDumpOptions,\n FromJSOptions,\n ParseWarning,\n ToCBOROptions,\n ToCDNOptions,\n ToHexDumpOptions,\n ToJSOptions,\n ValidateOptions,\n ValidateResult,\n} from './types';\nimport { CBOR_OMIT } from './types';\nimport { decodeCBOR } from './cbor/decoder';\nimport { parseCDN } from './cdn/parser';\nimport { CdnSyntaxError } from './cdn/errors';\nimport { dt_as_Date as _dt_as_Date } from './extensions/dt';\nimport { fromJS as _fromJS, _applyReplacer } from './js/fromJS';\nimport { MapEntries as _MapEntries } from './mapEntries';\nimport { Simple as _Simple } from './simple';\nimport { CBOR_TAG, Tag as _Tag } from './tag';\n\n/**\n * Main facade class.\n *\n * Provides factory methods for constructing AST nodes from the three\n * supported input formats, and shortcut methods that mirror the\n * `JSON.parse` / `JSON.stringify` API.\n *\n * @example\n * // CBOR binary → AST → CBOR binary\n * const ast = CBOR.fromCBOR(bytes);\n * const reencoded = ast.toCBOR();\n *\n * @example\n * // JS value → CBOR binary (shortcut)\n * const bytes = CBOR.encode({ hello: 'world' });\n *\n * @example\n * // CBOR binary → JS value (shortcut)\n * const value = CBOR.decode(bytes);\n */\nexport class CBOR {\n /**\n * Sentinel returned from a replacer or reviver to omit the key/element from\n * the output. Use this instead of `undefined` when `undefinedOmits` is\n * `false` (the default) and you need to drop a specific entry.\n */\n static readonly OMIT: typeof CBOR_OMIT = CBOR_OMIT;\n\n /** Unique symbol used to attach a CBOR tag number to a JS value. */\n static readonly TAG: typeof CBOR_TAG = CBOR_TAG;\n\n /** Namespace for CBOR tag annotation utilities. */\n static readonly Tag: typeof _Tag = _Tag;\n\n /** Wrapper for CBOR simple values other than false/true/null/undefined. */\n static readonly Simple: typeof _Simple = _Simple;\n\n /** Array subclass used to preserve CBOR map entries, including duplicates. */\n static readonly MapEntries: typeof _MapEntries = _MapEntries;\n\n /** Extension that maps CDN dt/DT values to JavaScript Date objects. */\n static readonly dt_as_Date: typeof _dt_as_Date = _dt_as_Date;\n\n // ─── Instance API ───────────────────────────────────────────────────────────\n\n readonly #defaults: CBOROptions;\n\n /**\n * Create a reusable instance with default options applied to every method call.\n * Per-call options always override these defaults.\n *\n * @example\n * const cbor = new CBOR({ extensions: [CBOR.dt_as_Date] });\n * const obj = cbor.parse('{ \"dt\": DT\\'2024-01-01T00:00:00Z\\' }');\n * const text = cbor.stringify(obj);\n */\n constructor(defaults?: CBOROptions) {\n this.#defaults = defaults ?? {};\n }\n\n #merge<T extends object>(perCall?: T): CBOROptions & T {\n return { ...this.#defaults, ...(perCall ?? {}) } as CBOROptions & T;\n }\n\n fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n const node = CBOR.fromCBOR(input, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromCDN(text: string, options?: FromCDNOptions): CborItem {\n const node = CBOR.fromCDN(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n /** @deprecated Use `fromCDN()` instead. */\n fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return this.fromCDN(text, options);\n }\n\n fromJS(value: unknown, options?: FromJSOptions): CborItem {\n const node = CBOR.fromJS(value, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const node = CBOR.fromHexDump(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromCBORSeq(input, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromCDNSeq(text: string, options?: FromCDNSeqOptions): Generator<CborItem> {\n for (const item of CBOR.fromCDNSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromHexDumpSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.decode(input, this.#merge(options));\n }\n\n *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.decodeSeq(input, this.#merge(options));\n }\n\n *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.parseSeq(text, this.#merge(options));\n }\n\n encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array {\n return CBOR.encode(value, this.#merge(options));\n }\n\n compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.compile(text, this.#merge(options));\n }\n\n decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return CBOR.decompile(input, this.#merge(options));\n }\n\n toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return CBOR.toHex(input, this.#merge(options));\n }\n\n fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromHex(text, this.#merge(options));\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n */\n validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n return CBOR.validate(input, this.#merge(options));\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return this.cborToCdn(input, options);\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n const merged = this.#merge(options);\n const node = CBOR.fromCBOR(input, merged);\n node._defaults = this.#defaults;\n return node.toCDN(merged);\n }\n\n /** @deprecated Use `compile()` instead. */\n cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return this.cdnToCbor(text, options);\n }\n\n /** @deprecated Use `compile()` instead. */\n cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n const merged = this.#merge(options);\n return CBOR.fromCDN(text, merged).toCBOR(merged);\n }\n\n parse(text: string): unknown;\n parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n const merged = this.#merge<ToJSOptions>({ reviver: arg2 });\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n const merged = this.#merge(arg2);\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n\n stringify(value: unknown): string;\n stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;\n stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const opts: FromJSOptions & ToCDNOptions = {\n ...(this.#defaults as FromJSOptions & ToCDNOptions),\n };\n if (arg2 === null) {\n opts.replacer = undefined;\n } else if (typeof arg2 === 'function' || Array.isArray(arg2)) {\n opts.replacer = arg2;\n }\n if (arg3 !== undefined) opts.indent = resolveSpace(arg3);\n return CBOR.stringify(value, opts);\n }\n return CBOR.stringify(value, this.#merge(arg2 ?? undefined));\n }\n\n format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.format(text, this.#merge(options));\n }\n\n // ─── Factory methods ────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data into an AST node. */\n static fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n return decodeCBOR(input, options);\n }\n\n /** Parse a CDN text string into an AST node. */\n static fromCDN(text: string, options?: FromCDNOptions): CborItem {\n return parseCDN(text, options);\n }\n\n /**\n * Parse a CDN text string into an AST node.\n *\n * @deprecated Use `fromCDN()` instead.\n */\n static fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return CBOR.fromCDN(text, options);\n }\n\n /** アノテーション付き hex dump テキストから CBOR Sequence を item ごとにデコードするジェネレータ。 */\n static *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n yield* CBOR.fromCBORSeq(new Uint8Array(bytes), options);\n }\n\n /** CBOR Sequence (RFC 8742) を item ごとにデコードするジェネレータ。 */\n static *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n const bytes =\n input instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' &&\n input instanceof SharedArrayBuffer)\n ? new Uint8Array(input)\n : new Uint8Array(\n (input as ArrayBufferView).buffer,\n (input as ArrayBufferView).byteOffset,\n (input as ArrayBufferView).byteLength\n );\n let offset = 0;\n while (offset < bytes.byteLength) {\n const item = decodeCBOR(bytes, {\n ...options,\n offset,\n allowTrailing: true,\n });\n yield item;\n offset = item.end!;\n }\n }\n\n /**\n * CDN テキストの複数 item を 1 つずつパースするジェネレータ。\n *\n * `preserveComments` が有効な場合、item 間のコメントは次の item の\n * leading コメントとして、item と同じ行にあるコメントはその item の\n * trailing コメントとして付与される。最後の item の後の行にだけ\n * コメントが残る場合、そのコメントはどの item にも属さず破棄される。\n */\n static *fromCDNSeq(\n text: string,\n options?: FromCDNSeqOptions\n ): Generator<CborItem> {\n const preserve = !!options?.preserveComments;\n let offset = 0;\n let isFirst = true;\n while (true) {\n const {\n offset: next,\n hadSeparator,\n commaOffset,\n } = skipCDNSeparator(\n text,\n offset,\n options,\n preserve ? (isFirst ? 'all' : 'after-newline') : 'none'\n );\n // Leading comma: comma before the first item (including comma-only input).\n // Checked before the EOF break so that \",\" alone is also caught.\n // Trailing comma is valid per ABNF SOC = S [\",\" S] and is silently accepted.\n if (isFirst && commaOffset >= 0) {\n const msg = 'leading comma in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, commaOffset, options);\n }\n if (next >= text.length) break;\n // Stopped at a comment that should lead the next item: make sure an\n // item actually follows. If only comments remain, we are done (the\n // remaining comments belong to no item and are dropped, matching the\n // behaviour of `preserveComments: false`).\n if (preserve && isCDNCommentStart(text, next)) {\n const lookahead = skipCDNSeparator(text, next, options);\n if (lookahead.offset >= text.length) break;\n }\n if (!isFirst && !hadSeparator) {\n const msg =\n 'CDN sequence items must be separated by whitespace, comma, or comment';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, next, options);\n }\n offset = next;\n let item: CborItem;\n try {\n // _skipRS: true causes the tokenizer to treat RS (U+001E, RFC 7464) as\n // whitespace, preventing it from corrupting string-literal contents via\n // a global text replacement.\n item = parseCDN(text, {\n ...options,\n offset,\n allowTrailing: true,\n _skipRS: true,\n } as FromCDNOptions);\n } catch (e) {\n if (options?.strict !== false) throw e;\n emitCDNSeqWarning(\n e instanceof Error ? e.message : String(e),\n offset,\n options,\n true,\n e instanceof CdnSyntaxError ? e : undefined\n );\n break;\n }\n yield item;\n offset = item.end!;\n isFirst = false;\n }\n }\n\n /** Convert a JavaScript value into an AST node. */\n static fromJS(value: unknown, options?: FromJSOptions): CborItem {\n return _fromJS(value, options);\n }\n\n /**\n * Parse an annotated hex dump (as produced by {@link CborItem#toHexDump})\n * into an AST node.\n *\n * Each line is expected to have the form:\n * `[whitespace] HH [HH …] -- comment`\n * `[whitespace] HH [HH …] # comment`\n * `[whitespace] HH [HH …] // comment`\n * Block comments may also be written as `/ comment /` or `/* comment *\\/`.\n * Lines with no hex content before the comment marker are ignored.\n */\n static fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n return decodeCBOR(new Uint8Array(bytes), options);\n }\n\n // ─── Shortcut API ───────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data directly to a JavaScript value. */\n static decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.fromCBOR(input, options).toJS(options);\n }\n\n /** Decode a CBOR Sequence (RFC 8742), yielding each item as a JavaScript value. */\n static *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCBORSeq(input, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Parse a CDN Sequence text string, yielding each item as a JavaScript value. */\n static *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCDNSeq(text, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Encode a JavaScript value directly to CBOR binary data. */\n static encode(\n value: unknown,\n options?: FromJSOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromJS(value, options).toCBOR(options);\n }\n\n /**\n * Compile a CDN text string to CBOR binary data.\n * Multi-item CDN Sequences produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromCDNSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Decompile CBOR binary data to a CDN text string.\n * CBOR Sequences (RFC 8742) produce multi-item CDN output, with items separated by newlines.\n */\n static decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toCDN(options))\n .join('\\n');\n }\n\n /**\n * Convert CBOR binary data to an annotated hex dump string.\n * CBOR Sequences (RFC 8742) produce one dump per item, separated by newlines.\n */\n static toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toHexDump(options))\n .join('\\n');\n }\n\n /**\n * Parse an annotated hex dump string to CBOR binary data.\n * Multi-item dumps produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromHexDumpSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n *\n * Decodes/parses the input as a sequence (CBOR Sequence per RFC 8742, or a\n * CDN Sequence) in non-strict mode: recoverable violations are collected\n * into `warnings` instead of stopping decoding, while malformed input\n * (e.g. truncated data, hard syntax errors — including a CDN Sequence\n * abandoned after a hard syntax error) is reported via `error`.\n * Informational hints about optional extensions that aren't registered\n * (`ParseWarning.hint`) are not treated as violations; they are collected\n * separately into `hints`.\n *\n * @example\n * const result = CBOR.validate(bytes);\n * if (!result.valid) {\n * if (result.error) console.error(`invalid: ${result.error.message}`);\n * for (const w of result.warnings) console.warn(w.message);\n * }\n *\n * @example\n * // CDN text input\n * CBOR.validate('{\"a\": 1}', { type: 'cdn' });\n */\n static validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n const warnings: (DecodeWarning | ParseWarning)[] = [];\n const hints: ParseWarning[] = [];\n let fatal: ParseWarning | undefined;\n const seqOptions = {\n strict: false,\n extensions: options?.extensions,\n builtinExtensions: options?.builtinExtensions,\n onWarning: (w: DecodeWarning | ParseWarning) => {\n if ('hint' in w && w.hint) {\n hints.push(w);\n return;\n }\n if ('fatal' in w && w.fatal) {\n fatal = w;\n return;\n }\n warnings.push(w);\n },\n };\n let count = 0;\n try {\n const type = options?.type ?? 'cbor';\n if (type === 'cdn') {\n const cdnOptions: FromCDNSeqOptions = {\n ...seqOptions,\n unresolvedExtension: options?.unresolvedExtension,\n };\n for (const _ of CBOR.fromCDNSeq(input as string, cdnOptions)) count++;\n } else if (type === 'hex') {\n for (const _ of CBOR.fromHexDumpSeq(input as string, seqOptions))\n count++;\n } else {\n for (const _ of CBOR.fromCBORSeq(\n input as ArrayBufferView | ArrayBufferLike,\n seqOptions\n ))\n count++;\n }\n } catch (err) {\n return {\n valid: false,\n count,\n warnings,\n hints,\n error: err instanceof Error ? err : new Error(String(err)),\n };\n }\n if (fatal) {\n // Prefer the original syntax error (position fields intact); the\n // unterminated-comment fatals are emitted without one, so rebuild a\n // CdnSyntaxError carrying at least the warning's offset.\n const error =\n fatal.cause instanceof Error\n ? fatal.cause\n : new CdnSyntaxError(fatal.message, { offset: fatal.offset });\n return { valid: false, count, warnings, hints, error };\n }\n return { valid: warnings.length === 0, count, warnings, hints };\n }\n\n /**\n * Convert CBOR binary data directly to a CDN text string.\n *\n * @deprecated Use `CBOR.decompile()` instead.\n */\n static cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /** @deprecated Use `CBOR.decompile()` instead. */\n static cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /**\n * Convert a CDN text string directly to CBOR binary data.\n *\n * @deprecated Use `CBOR.compile()` instead.\n */\n static cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /** @deprecated Use `CBOR.compile()` instead. */\n static cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /**\n * Parse a CDN text string directly to a JavaScript value.\n *\n * Accepts either a JSON-compatible `reviver` function as the second argument,\n * or a plain options object (existing API).\n *\n * When a `reviver` is supplied it is applied bottom-up after the CDN text has\n * been parsed and converted to a JS value, matching the semantics of\n * `JSON.parse(text, reviver)`.\n *\n * Note: CBOR-specific value types such as `bigint` are passed to the reviver\n * as-is; the reviver is responsible for handling them.\n */\n static parse(text: string): unknown;\n static parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n static parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n return CBOR.fromCDN(text).toJS({ reviver: arg2 });\n }\n return CBOR.fromCDN(text, arg2).toJS(arg2);\n }\n\n /**\n * Serialize a JavaScript value directly to a CDN text string.\n *\n * Accepts either JSON-compatible `replacer` + `space` arguments, or a plain\n * options object (existing API).\n *\n * - `replacer` may be a function (transforms each key/value before encoding)\n * or an array of strings/numbers (allowlist of object keys to include).\n * Pass `null` to skip filtering.\n * - `space` controls indentation, mapping to `ToCDNOptions.indent`.\n * Numbers are clamped to `[0, 10]`; strings are truncated to 10 characters.\n */\n static stringify(value: unknown): string;\n static stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n static stringify(\n value: unknown,\n options: FromJSOptions & ToCDNOptions\n ): string;\n static stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const replacer =\n typeof arg2 === 'function' || Array.isArray(arg2) ? arg2 : undefined;\n const indent = resolveSpace(arg3);\n if (replacer) {\n // Mirror JSON.stringify: if the replacer drops the root, return undefined.\n const replaced = _applyReplacer(value, replacer);\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n return _fromJS(replaced).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n return _fromJS(value).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n // Options form: also mirror JSON.stringify root-drop semantics.\n const opts = arg2 as (FromJSOptions & ToCDNOptions) | undefined;\n if (opts?.replacer) {\n const replaced = _applyReplacer(\n value,\n opts.replacer,\n opts.extensions,\n opts.undefinedOmits,\n opts.builtinExtensions\n );\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n const { replacer: _r, ...restFromJS } = opts;\n return _fromJS(\n replaced,\n Object.keys(restFromJS).length > 0\n ? (restFromJS as FromJSOptions)\n : undefined\n ).toCDN(opts);\n }\n return _fromJS(value, opts as FromJSOptions | undefined).toCDN(opts);\n }\n\n /** Normalize a CDN text string by parsing and re-serializing it. */\n static format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.fromCDN(text, options).toCDN(options);\n }\n}\n\nfunction stripHexDumpComments(text: string): string {\n let out = '';\n let i = 0;\n\n while (i < text.length) {\n const ch = text[i];\n const next = text[i + 1] ?? '';\n\n if (ch === '-' && next === '-') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '—') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '#') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '/') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '*') {\n const end = text.indexOf('*/', i + 2);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 2));\n i = end + 2;\n continue;\n }\n\n if (ch === '/') {\n const end = text.indexOf('/', i + 1);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 1));\n i = end + 1;\n continue;\n }\n\n out += ch;\n i++;\n }\n\n return out;\n}\n\nfunction skipLineComment(text: string, start: number): number {\n const end = text.indexOf('\\n', start);\n return end < 0 ? text.length : end;\n}\n\nfunction whitespaceLike(text: string): string {\n return text.replace(/[^\\r\\n]/g, ' ');\n}\n\n// ─── Module-scope helper ─────────────────────────────────────────────────────\n\nfunction emitCDNSeqWarning(\n msg: string,\n fallbackOffset: number,\n options: FromCDNSeqOptions | undefined,\n fatal?: boolean,\n cause?: CdnSyntaxError\n): void {\n const offset = cause?.offset ?? fallbackOffset;\n const w: ParseWarning = { message: msg, offset };\n if (fatal) w.fatal = true;\n if (cause) w.cause = cause;\n if (cause?.offset !== undefined) {\n w.line = cause.line;\n w.column = cause.column;\n w.endOffset = cause.endOffset;\n }\n if (options?.onWarning) options.onWarning(w);\n else if (!options?.silent)\n console.warn(`CDN sequence warning at offset ${offset}: ${msg}`);\n}\n\n/** Whether `text[i]` starts a CDN comment (`#`, `//`, `/* … *\\/`, or `/ … /`). */\nfunction isCDNCommentStart(text: string, i: number): boolean {\n const ch = text[i];\n return ch === '#' || ch === '/';\n}\n\n/**\n * CDN sequence の item 間にある空白・コメント・省略可能なカンマを読み飛ばし、\n * 次の item が始まる文字位置と、何らかの separator が存在したかどうかを返す。\n * 未終端のブロックコメントは strict モードでは throw し、\n * strict: false の場合は警告を emit して末尾まで読み飛ばす。\n *\n * `stopAtComments` は `preserveComments` 有効時にコメントを次の item の\n * leading コメントとして残すためのモード:\n * - `'none'`: コメントも読み飛ばす(従来動作)\n * - `'all'`: 最初のコメントで停止する(先頭 item 用)\n * - `'after-newline'`: 改行より後のコメントで停止する。直前 item と同じ行の\n * コメントはその item の trailing コメントとして既に付与されているため読み飛ばす。\n */\nfunction skipCDNSeparator(\n text: string,\n from: number,\n options: FromCDNSeqOptions | undefined,\n stopAtComments: 'none' | 'after-newline' | 'all' = 'none'\n): { offset: number; hadSeparator: boolean; commaOffset: number } {\n let i = from;\n let hadSeparator = false;\n let seenComma = false;\n let seenNewline = false;\n let commaOffset = -1;\n const stopHere = (): boolean =>\n stopAtComments === 'all' ||\n (stopAtComments === 'after-newline' && seenNewline);\n while (i < text.length) {\n const ch = text[i];\n if (ch === ' ' || ch === '\\t' || ch === '\\r' || ch === '\\x1e') {\n hadSeparator = true;\n i++;\n continue;\n }\n if (ch === '\\n') {\n hadSeparator = true;\n seenNewline = true;\n i++;\n continue;\n }\n if (ch === '#') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 1);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 2);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '*') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('*/', i + 2);\n if (end < 0) {\n const msg = 'unterminated /* comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 2;\n }\n continue;\n }\n if (ch === '/' && text[i + 1] !== '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('/', i + 1);\n if (end < 0) {\n const msg = 'unterminated / comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 1;\n }\n continue;\n }\n if (ch === ',' && !seenComma) {\n hadSeparator = true;\n seenComma = true;\n commaOffset = i;\n i++;\n continue;\n }\n break;\n }\n return { offset: i, hadSeparator, commaOffset };\n}\n\n/** Map JSON.stringify `space` argument to ToCDNOptions.indent. */\nfunction resolveSpace(\n space: string | number | undefined\n): string | number | undefined {\n if (typeof space === 'number') {\n const n = Math.floor(Math.min(10, Math.max(0, space)));\n return n === 0 ? undefined : n;\n }\n if (typeof space === 'string') {\n const s = space.slice(0, 10);\n return s || undefined;\n }\n return undefined;\n}\n"],"mappings":";;;AAIA,IAAM,IAAY,oCACZ,IAAY;AAElB,SAAS,EAAmB,GAAqB;CAC/C,IAAI,IAAM,EAAI;CACd,OAAO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GACvC,IAAI,EAAK;GACX,OAEE,AADI,EAAK,MAAM,GAAG,CAAG,CAAC,CAAC,SAAS,IAAI,MAAG,IAAc,KACrD,IAAI,IAAM;GAEZ;EACF;EACA,IAAI,MAAO,OAAO,CAAC,GAAW;GAI5B,AAHA,IAAe,IACf,IAAY,IACZ,IAAc,GACd;GACA;EACF;EACA;CACF;CACA,OAAO;EAAE,QAAQ;EAAG;EAAc;CAAY;AAChD;AAGA,SAAS,EACP,GAC6B;CAC7B,IAAI,OAAO,KAAU,UAAU;EAC7B,IAAM,IAAI,KAAK,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,CAAK,CAAC,CAAC;EACrD,OAAO,MAAM,IAAI,KAAA,IAAY;CAC/B;CACA,IAAI,OAAO,KAAU,UAEnB,OADU,EAAM,MAAM,GAAG,EAClB,KAAK,KAAA;AAGhB"}
@@ -4,12 +4,12 @@ const e=require("./tokenizer-EciPlN0n.cjs");var t=Symbol.for(`cbor.tag`),n=class
4
4
  `)}toEDN(e){return this.toCDN(e)}toJS(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toJS(t);if(!t?.reviver)return n;let r=t.reviver.call({"":n},``,n);return r===u?void 0:r}toHexDump(e){let t=this._defaults?{...this._defaults,...e}:e,n=t?.indent??3,r=typeof n==`string`?n:` `.repeat(n),i=(t?.commentStyle??`--`)+` `,a=this._toHexDump(0,t),o=0;for(let e of a){let t=e.depth*r.length+e.hex.length;t>o&&(o=t)}let s=o+2;return a.map(e=>(r.repeat(e.depth)+e.hex).padEnd(s)+i+e.comment).join(`
5
5
  `)}_encode(e,n){if(this._toCBOR!==t.prototype._toCBOR){e.writeBytes(this._toCBOR(n));return}this._encodeTo(e,n)}_encodeTo(e,n){if(this._toCBOR===t.prototype._toCBOR)throw TypeError(`CborItem subclass must implement _encodeTo() or _toCBOR()`);e.writeBytes(this._toCBOR(n))}_toCBOR(e){let t=new Oe;return this._encodeTo(t,e),t.finish()}_toHexDump(t,n){return[{depth:t,hex:e.i(this._toCBOR()),comment:this._toCDN(n,0)}]}},O=class extends D{value;encodingWidth;constructor(e,t){if(super(),this.value=BigInt(e),this.value<0n)throw RangeError(`CborUint value must be non-negative`);if(this.value>18446744073709551615n)throw RangeError(`CborUint value exceeds maximum uint64`);this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){T(e,0,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.value)),r=this.value;switch(e?.intFormat){case`hex`:return`0x${r.toString(16)}${n}`;case`octal`:return`0o${r.toString(8)}${n}`;case`binary`:return`0b${r.toString(2)}${n}`;default:return r.toString()+n}}_toJS(e){let t=e?.integerAs??`auto`;return t===`bigint`?this.value:t===`number`||this.value<=BigInt(2**53-1)?Number(this.value):this.value}},k=class extends D{argument;encodingWidth;constructor(e,t){super();let n=BigInt(e);if(n>=0n)throw RangeError(`CborNint value must be negative`);if(n<-18446744073709551616n)throw RangeError(`CborNint value exceeds minimum int64`);this.argument=-1n-n,this.encodingWidth=t?.encodingWidth}get value(){return-1n-this.argument}_encodeTo(e,t){T(e,1,this.argument,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.argument)),r=this.argument+1n;switch(e?.intFormat){case`hex`:return`-0x${r.toString(16)}${n}`;case`octal`:return`-0o${r.toString(8)}${n}`;case`binary`:return`-0b${r.toString(2)}${n}`;default:return this.value.toString()+n}}_toJS(e){let t=this.value,n=e?.integerAs??`auto`;return n===`bigint`?t:n===`number`||t>=BigInt(-(2**53-1))?Number(t):t}},Fe=new DataView(new ArrayBuffer(8));function Ie(e){let t=e.startsWith(`-`),n=e.slice(t?3:2),r=n.search(/[pP]/);if(r===-1)throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);let i=n.slice(0,r),a=n.slice(r+1);if(!/^[+-]?\d+$/.test(a))throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);let o=parseInt(a,10),s=i.indexOf(`.`),c;if(s===-1){if(!/^[0-9a-fA-F]+$/.test(i))throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);c=parseInt(i,16)}else{let t=i.slice(0,s),n=i.slice(s+1);if(t===``&&n===``)throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);if(t!==``&&!/^[0-9a-fA-F]+$/.test(t)||n!==``&&!/^[0-9a-fA-F]+$/.test(n))throw SyntaxError(`EDN parse error: hex float has invalid mantissa: ${e}`);c=(t===``?0:parseInt(t,16))+(n===``?0:parseInt(n,16)/16**n.length)}let l=c*2**o;return t?-l:l}function Le(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;let t=Object.is(e,-0)||e<0,n=Math.abs(e);if(n===0)return t?`-0x0p+0`:`0x0p+0`;Fe.setFloat64(0,n,!1);let r=Fe.getUint32(0,!1),i=Fe.getUint32(4,!1),a=r>>>20&2047,o=r&1048575,s=i,c=(o.toString(16).padStart(5,`0`)+s.toString(16).padStart(8,`0`)).replace(/0+$/,``),l=c===``?``:`.${c}`,u,d;a===0?(u=`0`,d=-1022):(u=`1`,d=a-1023);let f=d>=0?`+${d}`:`${d}`,p=`0x${u}${l}p${f}`;return t?`-${p}`:p}var A=class extends D{value;precision;ednSource;rawBits;constructor(e,t){super(),this.value=e,this.precision=t?.precision,this.rawBits=t?.rawBits}_encodeTo(e,t){let n=this.precision??E(this.value),r=Number.isNaN(this.value)?this.rawBits:void 0;n===`half`?(e.writeByte(249),r?.length===2?e.writeBytes(r):e.writeFloat16(this.value)):n===`single`?(e.writeByte(250),r?.length===4?e.writeBytes(r):e.writeFloat32(this.value)):(e.writeByte(251),r?.length===8?e.writeBytes(r):e.writeFloat64(this.value))}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;if(e?.appStrings!==!1&&this.ednSource!==void 0){if(n===`never`)return this.ednSource.replace(/_[0-3i]$/,``);if(n===`always`){if(/_[0-3i]$/.test(this.ednSource))return this.ednSource;let e=this.precision??E(this.value),t=e===`half`?`_1`:e===`single`?`_2`:`_3`;return this.ednSource+t}return this.ednSource}let r=E(this.value);return(e?.floatFormat===`hex`?Le(this.value):ve(this.value))+ye(this.value,this.precision,r,n)}_toJS(e){return this.value}},j=class extends D{tag;content;encodingWidth;constructor(e,t,n){if(super(),this.tag=BigInt(e),this.tag<0n)throw RangeError(`CborTag tag number must be non-negative`);this.content=t,this.encodingWidth=n?.encodingWidth}get _containsCdnContainer(){return this.content._containsCdnContainer}_encodeTo(e,t){T(e,6,this.tag,this.encodingWidth),this.content._encode(e,t)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.tag));return`${this.tag}${n}(${this.content._toCDN(e,t)})`}_toHexDump(t,n){let r=[{depth:t,hex:e.i(je(6,this.tag,this.encodingWidth)),comment:`Tag ${this.tag}`}];return r.push(...this.content._toHexDump(t+1,{...n,appStrings:!1})),r}_toJS(e){let t=this.content._toJS(e);return e?.stripTags?t:l.set(t,this.tag)}},M=class extends D{indefiniteLength=!1;value;ednEncoding;encodingWidth;ednSource;ednParts;constructor(e,t){super(),this.value=e,this.ednEncoding=t?.ednEncoding??`hex`,this.encodingWidth=t?.encodingWidth,this.ednSource=t?.ednSource,this.ednParts=t?.ednParts}_encodeTo(e,t){T(e,2,this.value.length,this.encodingWidth),e.writeBytes(this.value)}_toCDN(e,t){if(e?.preserveConcatenation&&this.ednParts!==void 0&&this.ednParts.length>1){let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),r=e?.bstrEncoding??this.ednEncoding;e?.appStrings===!1&&r!==`hex`&&(r=`hex`);let i=this.ednParts.map(t=>e?.preserveByteString&&t.source!==void 0?t.source:ue(t.bytes,r,e?.sqstr));return i[i.length-1]+=n,m(i,f(e),t)}if(e?.preserveByteString&&this.ednSource!==void 0){if(/_[0-3i]$/.test(this.ednSource))return(e?.encodingIndicators??`auto`)===`never`?this.ednSource.replace(/_[0-3i]$/,``):this.ednSource;let t=x(e,this.encodingWidth,()=>b(BigInt(this.value.length)));return this.ednSource+t}let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),r=e?.bstrEncoding??this.ednEncoding;return e?.appStrings===!1&&r!==`hex`&&(r=`hex`),ue(this.value,r,e?.sqstr)+n}_toJS(e){return this.value}},N=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(95);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){if((e?.encodingIndicators??`auto`)===`never`){let n=this.chunks.reduce((e,t)=>e+t.value.length,0),r=new Uint8Array(n),i=0;for(let e of this.chunks)r.set(e.value,i),i+=e.value.length;return new M(r)._toCDN(e,t)}return this.chunks.length===0?`''_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(95),comment:`Start indefinite-length byte string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){let t=this.chunks.reduce((e,t)=>e+t.value.length,0),n=new Uint8Array(t),r=0;for(let e of this.chunks)n.set(e.value,r),r+=e.value.length;return n}},P=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(127);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){return(e?.encodingIndicators??`auto`)===`never`?new B(this.chunks.map(e=>e.value).join(``))._toCDN(e,t):this.chunks.length===0?`""_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(127),comment:`Start indefinite-length text string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){return this.chunks.map(e=>e.value).join(``)}},F=class extends D{items;indefiniteLength;encodingWidth;constructor(e,t){super(),this.items=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(159);for(let n of this.items)n._encode(e,t);e.writeByte(255);return}T(e,4,this.items.length,this.encodingWidth);for(let n of this.items)n._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`[`,closeChar:`]`,count:this.items.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.items.some(h),renderEntry:n=>this.items[n]._toCDN(e,t+1),entryIsLeaf:e=>!this.items[e]._containsCdnContainer,entryLeadingNode:e=>this.items[e],entryTrailing:(e,t)=>_(this.items[e],t)})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(159),comment:`Start indefinite-length array`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(4,BigInt(this.items.length),this.encodingWidth)),comment:`Array of length ${this.items.length}`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver;if(!t)return this.items.map(t=>t._toJS(e));let n=e?{...e,reviver:void 0}:void 0,r=this.items.map(e=>e._toJS(n)),i=0;for(let n=0;n<this.items.length;n++){let a=n-i,o=this.items[n]._toJS(e),s=t.call(r,String(n),o);s===u||e?.undefinedOmits&&s===void 0?(r.splice(a,1),i++):r[a]=s}return r}},I=class extends D{entries;indefiniteLength;encodingWidth;constructor(e,t){super(),this.entries=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(191);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t);e.writeByte(255);return}T(e,5,this.entries.length,this.encodingWidth);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`{`,closeChar:`}`,count:this.entries.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.entries.some(([e,t])=>h(e)||h(t)),renderEntry:(n,r)=>{let[i,a]=this.entries[n];return`${i._toCDN(e,t+1)}${r}${a._toCDN(e,t+1)}`},entryIsLeaf:e=>{let[t,n]=this.entries[e];return!t._containsCdnContainer&&!n._containsCdnContainer},entryLeadingNode:e=>this.entries[e][0],entryTrailing:(e,t)=>{let[n,r]=this.entries[e];return Re([...n.comments?.trailing??[],...r.comments?.leading??[],...r.comments?.trailing??[]],t)}})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(191),comment:`Start indefinite-length map`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(5,BigInt(this.entries.length),this.encodingWidth)),comment:`Map of length ${this.entries.length}`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver,n=()=>{let n=$.from(this.entries,([t,n])=>[t._toJS(e),n._toJS(e)]);if(!t)return n;let r=e?.undefinedOmits;for(let e=0;e<n.length;e++){let[i,a]=n[e],o=t.call(n,i,a);o===u||r&&o===void 0?n.splice(e--,1):n[e]=[i,o]}return n};return e?.mapAs===`entries`?n():e?.mapAs===`object`||this.entries.every(([e])=>e instanceof B)?(()=>{let n=e?{...e,reviver:void 0}:void 0,r={};for(let[e,t]of this.entries){let i=e instanceof B?e.value:e.toCDN(),a=t._toJS(n);i===`__proto__`?Object.defineProperty(r,i,{value:a,writable:!0,enumerable:!0,configurable:!0}):r[i]=a}if(!t)return r;let i=new Map;for(let e=0;e<this.entries.length;e++){let[t]=this.entries[e];i.set(t instanceof B?t.value:t.toCDN(),e)}for(let n=0;n<this.entries.length;n++){let[a,o]=this.entries[n],s=a instanceof B?a.value:a.toCDN();if(i.get(s)!==n)continue;let c=o._toJS(e),l=t.call(r,s,c);l===u||e?.undefinedOmits&&l===void 0?delete r[s]:s===`__proto__`?Object.defineProperty(r,s,{value:l,writable:!0,enumerable:!0,configurable:!0}):r[s]=l}return r})():n()}};function Re(e,t){return e.length===0?``:` `+e.map(e=>g(e,t).trimEnd()).join(` `)}var L=class e extends D{value;constructor(e){if(super(),!Number.isInteger(e)||e<0||e>255)throw RangeError(`CborSimple value must be an integer in 0–255`);this.value=e}static FALSE=new e(20);static TRUE=new e(21);static NULL=new e(22);static UNDEFINED=new e(23);_encodeTo(e,t){if(this.value<=23){e.writeByte(224|this.value);return}e.writeByte(248),e.writeByte(this.value)}_toCDN(e,t){switch(this.value){case 20:return`false`;case 21:return`true`;case 22:return`null`;case 23:return`undefined`;default:return`simple(${this.value})`}}_toJS(e){switch(this.value){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new d(this.value)}}},ze=class extends D{items;encodingWidth;constructor(e,t){super(),this.items=e,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return this.items.some(e=>e._containsCdnContainer)}_content(e){let t=new Oe;for(let n of this.items)n._encode(t,e);return t.finish()}_encodeTo(e,t){let n=this._content(t);T(e,2,n.length,this.encodingWidth),e.writeBytes(n)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(this._content(e).length)));if(this.items.length===0)return`<<>>${n}`;let r=f(e),{inlineSep:i,multilineSep:a,trailSep:o}=re(e,r===null);if(r===null)return`<<${this.items.map(n=>n._toCDN(e,t+1)).join(i)}>>${n}`;let s=p(r,t+1),c=p(r,t),l=this.items.map(n=>`${s}${n._toCDN(e,t+1)}`),u=l.length-1;return`<<\n${l.map((e,t)=>t<u?`${e}${a}`:`${e}${o}`).join(`
6
6
  `)}\n${c}>>${n}`}_toHexDump(t,n){let r=this._content().length,i=[{depth:t,hex:e.i(je(2,BigInt(r),this.encodingWidth)),comment:`Embedded CBOR sequence, ${r} byte${r===1?``:`s`}`}];for(let e of this.items)i.push(...e._toHexDump(t+1,n));return i}_toJS(e){return this._content()}},Be=999n,Ve=class extends j{constructor(e,t){let n=t.length===1&&t[0]instanceof B?t[0]:new F(t);super(Be,new F([new B(e),n]))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content,r=n.items[0].value,i=n.items[1];return i instanceof B?`${r}${ge(i.value)}`:`${r}<<${i.items.map(n=>n._toCDN(e,t)).join(`, `)}>>`}},He=class extends D{inner;ednSource;constructor(e,t){super(),this.inner=e,this.ednSource=t}get _containsCdnContainer(){return this.inner._containsCdnContainer}_encodeTo(e,t){this.inner._encode(e,t)}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;return e?.appStrings!==!1&&n===`auto`?this.ednSource:this.inner._toCDN(e,t)}_toJS(e){return this.inner._toJS(e)}},Ue=888n,R=class extends j{constructor(e){e===void 0?super(Ue,L.NULL):super(Ue,new F(e))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);if(this.content instanceof L)return`...`;if(this.content instanceof F){let n=this.content.items.map(n=>n._toCDN(e,t));return n.length===0?``:m(n,f(e),t)}return super._toCDN(e,t)}},We=2n,Ge=3n,Ke=18446744073709551615n,qe=-18446744073709551616n;function Je(e){if(e<0n)throw RangeError(`bigintToBytes requires a non-negative value`);if(e===0n)return new Uint8Array;let t=e.toString(16);t.length%2!=0&&(t=`0`+t);let n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function Ye(e){let t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var Xe=class extends j{bigValue;constructor(e){if(e<=Ke)throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);super(We,new M(Je(e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Ze=class extends j{bigValue;constructor(e){if(e>=qe)throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);super(Ge,new M(Je(-1n-e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Qe=new TextEncoder,$e=new TextDecoder(`utf-8`,{fatal:!0}),et=new TextDecoder(`utf-8`,{fatal:!1});function tt(t,n){let r=new e.t(t,{offset:n?.offset,skipRS:n?._skipRS}),i=new pt(r,n??{}).parse();return n?.preserveComments&&ot(i,r.comments,t),i}function nt(e){let t=e,n;return/[_][0-7i]$/.test(e)&&(n=e[e.length-1],t=e.slice(0,-2)),{numStr:t,rawSuffix:n}}function rt(e){return e.startsWith(`-`)?-BigInt(e.slice(1)):BigInt(e)}function it(e,t){if(e.endsWith(`_i`)||e.endsWith(`_0`)){let n=`_0 and _i encoding indicators are not valid for floating-point values`;if(t)t(n),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${n}`)}else if(/[_][4567]$/.test(e)){let n=e[e.length-1],r=n===`7`?`indefinite-length encoding (_7) is not valid for floating-point values`:`encoding indicator _${n} (AI ${Number(n)+24}) is reserved and not valid`;if(t)t(r),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${r}`)}if(e===`NaN`)return{value:NaN,precision:void 0};if(e===`Infinity`)return{value:1/0,precision:void 0};if(e===`-Infinity`)return{value:-1/0,precision:void 0};let n=e,r;return e.endsWith(`_1`)?(r=`half`,n=e.slice(0,-2)):e.endsWith(`_2`)?(r=`single`,n=e.slice(0,-2)):e.endsWith(`_3`)&&(r=`double`,n=e.slice(0,-2)),/^-?0[xX]/.test(n)?{value:Ie(n),precision:r}:{value:parseFloat(n),precision:r}}function at(e,t){let n=e.indexOf(`=`),r=n>=0?e.slice(0,n):e,i=n>=0?e.slice(n):``;if(/[^A-Za-z0-9+/\-_]/.test(r)){let e=[...r].find(e=>!/[A-Za-z0-9+/\-_]/.test(e))??``;throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`)}if(i&&!/^=+$/.test(i))throw SyntaxError(`invalid character after base64 '=' padding`);let a=r.length%4;if(a===1)throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);let o=a===0?0:4-a;if(i.length>o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but the data length (${r.length}) requires at most ${o}`;if(t)t(e);else throw SyntaxError(e)}if(i.length>0&&i.length<o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but needs exactly ${o} — use full padding or no padding at all`;if(t)t(e);else throw SyntaxError(e)}if(a!==0&&r.length>0){let e=r[r.length-1].replace(`-`,`+`).replace(`_`,`/`),n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e);if(n>=0&&n&(a===2?15:3)){let e=`base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)`;if(t)t(e);else throw SyntaxError(e)}}let s=r.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat(o);if(typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(s,{alphabet:`base64`,lastChunkHandling:`loose`});let c=atob(s),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);return l}function ot(e,t,n){if(t.length===0)return;let r=st(e),i=lt(n),a=[...r].sort((e,t)=>e.start-t.start||t.end-e.end),o=[...r].sort((e,t)=>e.end-t.end||e.start-t.start),s=[...t].sort((e,t)=>e.start-t.start),c=[],l=0;for(let t of s){let r={...t},s=0,u=o.length;for(;s<u;){let e=s+u>>1;o[e].end<=t.start?s=e+1:u=e}let d=s>0?o[s-1]:void 0,f=d?n.slice(d.end,t.start):``;if(d&&i(d.end)===t.line&&!f.includes(`:`)){ct(d.node,`trailing`,r);continue}for(;l<a.length&&a[l].start<t.start;){let e=a[l++];for(;c.length>0&&c[c.length-1].end<=e.start;)c.pop();c.push(e)}for(;c.length>0&&c[c.length-1].end<=t.start;)c.pop();let p=c.length>0?c[c.length-1]:void 0;for(s=0,u=a.length;s<u;){let e=s+u>>1;a[e].start<t.end?s=e+1:u=e}let m=s<a.length?a[s]:void 0;if((!p||m&&m.end<=p.end)&&m){ct(m.node,`leading`,r);continue}ct(p?.node??e,`dangling`,r)}}function st(e){let t=[],n=e=>{if(e.start!==void 0&&e.end!==void 0&&t.push({node:e,start:e.start,end:e.end}),e instanceof F||e instanceof ze){for(let t of e.items)n(t);return}if(e instanceof I){for(let[t,r]of e.entries)n(t),n(r);return}if(e instanceof N||e instanceof P){for(let t of e.chunks)n(t);return}e instanceof j&&n(e.content)};return n(e),t}function ct(e,t,n){e.comments??={},e.comments[t]??=[],e.comments[t].push(n)}function lt(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
7
- `&&t.push(n+1);return n=>{let r=Math.max(0,Math.min(e.length,n));r>0&&r===e.length&&r--;let i=0,a=t.length-1;for(;i<=a;){let e=i+a>>1;t[e]<=r?i=e+1:a=e-1}return a+1}}var ut=e=>`import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`,dt=(e,t)=>`install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`,z=e=>`'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`,ft=new Map([[`b32`,ut(`b32`)],[`h32`,ut(`h32`)],[`same`,ut(`same`)],[`hash`,dt(`hash`,`@cbortech/hash-extension`)],[`uuid`,dt(`uuid`,`@cbortech/uuid-extension`)],[`UUID`,dt(`uuid`,`@cbortech/uuid-extension`)],[`dt`,z(`dt`)],[`DT`,z(`dt`)],[`ip`,z(`ip`)],[`IP`,z(`ip`)],[`cri`,z(`cri`)],[`CRI`,z(`cri`)],[`t1`,z(`t1`)],[`b1`,z(`b1`)],[`ilbs`,z(`ilbs`)],[`ilts`,z(`ilts`)],[`float`,z(`float`)]]),pt=class{t;_options;extByPrefix;extByTag;unresolvedExtension;_pendingWarnings=[];_hintedPrefixes=new Set;constructor(t,n){this.t=t,this._options=n,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n.unresolvedExtension??`cpa999`;let r=Z(n.builtinExtensions);for(let e of[...r,...n.extensions??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}this.t.onEscapeWarning=(t,n,r,i,a)=>{let o={message:t,offset:n,line:r,column:i,endOffset:a};if(this._pendingWarnings.push(o),this._options.onWarning?this._options.onWarning(o):this._options.silent||console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`),this._options.strict!==!1)throw new e.o(t,{offset:n,line:r,column:i,endOffset:a})}}parse(){let e=this.parseValue();if(this._options.allowTrailing)return e;let t=this.t.peek();if(t.type!==`EOF`)for(this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`,t),this._pendingWarnings.length>0&&(e.warnings??=[],e.warnings.push(...this._pendingWarnings),this._pendingWarnings=[]);this.t.peek().type!==`EOF`;)this.t.consume();return e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();if(this.t.peek().type===`UNDERSCORE`){let e=this.t.consume();this._warnOrFail(`bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i`,e)}if(this._pendingWarnings.length>0){t.warnings??=[];for(let e of this._pendingWarnings)t.warnings.push(e);this._pendingWarnings=[]}return t.start=e,t.end=this.t.lastEndOffset,t}_parseValueNode(){let e=this.t.peek();switch(e.type){case`INTEGER`:return this.parseIntegerOrTag();case`FLOAT`:return this.parseFloat();case`TSTR`:case`RAWSTRING`:return this.parseString();case`BYTES_HEX`:case`SQSTR`:case`BYTES_B64`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new N([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new P([]);case`TRUE`:return this.t.consume(),new L(21);case`FALSE`:return this.t.consume(),new L(20);case`NULL`:return this.t.consume(),new L(22);case`UNDEFINED`:return this.t.consume(),new L(23);case`SIMPLE`:return this.parseSimple();case`LBRACKET`:return this.parseArray();case`LBRACE`:return this.parseMap();case`LPAREN`:return this.parseIndefGroup();case`LT_LT`:return this.parseEmbeddedCBOR();case`APP_STRING`:{this.t.consume();let t,n=``;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e),n=e.raw}let r=this.extByPrefix.get(e.appPrefix);if(!r?.parseAppString){if(r||this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,[new B(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}{let i=this._pendingWarnings.length;try{let i=r.parseAppString(e.appPrefix,e.value,this._extOnError(e),t===void 0?void 0:{encodingWidth:t});return t!==void 0&&this._applyEiToResult(i,t,e),i instanceof M&&Object.getPrototypeOf(i)===M.prototype&&i.ednSource===void 0?new M(i.value,{ednEncoding:i.ednEncoding,encodingWidth:i.encodingWidth,ednSource:e.raw+n}):(i instanceof A&&i.ednSource===void 0&&(i.ednSource=e.raw+n),i)}catch(t){if(this._options.strict!==!1)throw t;return this._pendingWarnings.length===i&&this._warn(t instanceof Error?t.message:String(t),e),new Ve(e.appPrefix,[new B(e.value)])}}}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`;){if(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),t.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());t.push(this.parseValue())}this.expect(`GT_GT`);let n,r;this.t.peek().type===`ENCODING_INDICATOR`&&(r=this.t.consume(),n=this._resolveEncodingWidth(r.value,r));let i=this.extByPrefix.get(e.appPrefix);if(!i){if(this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}i.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e);{let a=this._pendingWarnings.length;try{let a=i.parseAppSequence(e.appPrefix,t,this._extOnError(e));n!==void 0&&this._applyEiToResult(a,n,r??e);let o=this.t.source.slice(e.offset,this.t.lastEndOffset);if(a instanceof A)a.ednSource===void 0&&(a.ednSource=o);else if(i.preserveAppSeqSource)return new He(a,o);return a}catch(n){if(this._options.strict!==!1)throw n;return this._pendingWarnings.length===a&&this._warn(n instanceof Error?n.message:String(n),e),new Ve(e.appPrefix,t)}}}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new R;let e=[new R];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new R(e)}case`BYTES_HEX_ELIDED`:return this.t.consume(),this._parseHexElidedConcat(e);default:this._fail(`unexpected token: ${JSON.stringify(e.value)}`,e)}}parseIntegerOrTag(){let e=this.t.consume(),{numStr:t,rawSuffix:n}=nt(e.value),r=n===void 0?this.consumeEncodingIndicator():this._resolveEncodingWidth(n,e),i=rt(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Xe(i);if(i<-18446744073709551616n)return new Ze(i);if(r!==void 0){let t=i>=0n?i:-(i+1n);r=this._validateEncodingFit(t,r,e)}let a=i>=0n?new O(i,r===void 0?void 0:{encodingWidth:r}):new k(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof O||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this._pendingWarnings.splice(0),n=this.parseValue();this.expect(`RPAREN`);let i=a.value,o=this.extByTag.get(i);if(o?.parseTag){let e=o.parseTag(i,n);if(e!==void 0)return e instanceof j&&r!==void 0&&e.encodingWidth===void 0&&(e.encodingWidth=r),t.length>0&&(e.warnings??=[],e.warnings.push(...t)),e}let s=new j(i,n,r===void 0?void 0:{encodingWidth:r});return t.length>0&&(s.warnings??=[],s.warnings.push(...t)),s}return a}parseFloat(){let e=this.t.consume(),t=t=>this._warnOrFail(t,e),{value:n,precision:r}=it(e.value,t);if(r===`half`||r===`single`){let e=r===`half`?C(S(n)):Math.fround(n);Object.is(n,e)||isNaN(n)&&isNaN(e)||t(`${n} cannot be exactly represented as ${r===`half`?`f16 (_1)`:`f32 (_2)`}; use _3 or remove the indicator`)}return new A(n,r===void 0?void 0:{precision:r})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(e.value).length));return e.type===`RAWSTRING`?new B(e.value,{ednSource:e.raw,...t===void 0?{}:{encodingWidth:t}}):new B(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();e.type===`ELLIPSIS`?(this.t.consume(),n.push({ellipsis:!0}),t=!0):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),n.push(e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value})):this._isBytesToken(e.type)?(this.t.consume(),n.push({text:this._decodeUtf8(this._decodeBytesToken(e),e)})):this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!t){let e=n.map(e=>`text`in e?e.text:``),t=n.map(e=>`text`in e?e.source:void 0),r=e.join(``),i=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(r).length));return new B(r,{ednParts:e,...t.some(e=>e!==void 0)?{ednPartSources:t}:{},...i===void 0?{}:{encodingWidth:i}})}let r=[],i=[],a=()=>{let e=i.map(e=>e.text),t=e.join(``);if(t!==``){let n=i.map(e=>e.source);r.push(new B(t,{ednParts:e,...n.some(e=>e!==void 0)?{ednPartSources:n}:{}}))}i.length=0};for(let e of n)`ellipsis`in e?(a(),r.push(new R)):i.push(e);return a(),new R(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`}_hexToBytes(t,n){try{return e.a(t)}catch(t){if(t instanceof e.o||!(t instanceof SyntaxError))throw t;this._fail(t.message,n)}}_decodeBytesToken(t){let n=e=>this._warnOrFail(e,t);switch(t.type){case`SQSTR`:{let e=t._sqstrBytes;return e===void 0?this._hexToBytes(t.value,t):e}case`BYTES_HEX`:return this._hexToBytes(t.value,t);case`BYTES_B64`:try{return at(t.value,n)}catch(n){if(n instanceof e.o||!(n instanceof SyntaxError))throw n;this._fail(n.message,t)}default:this._fail(`expected byte string token`,t)}}_decodeUtf8(e,t){if(this._options.allowInvalidUtf8)return et.decode(e);try{return $e.decode(e)}catch{return this._warnOrFail(`byte string in text concatenation is not valid UTF-8`,t),et.decode(e)}}_tokenTypeToCdnEncoding(e){return e===`BYTES_B64`?`base64`:`hex`}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator(()=>BigInt(e.length));return new M(e,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e,source:n}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),i.push({ellipsis:!0}),r=!0;else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let t=this._buildBytesElidedItems(e.value,e);for(let e of t)e instanceof R?(i.push({ellipsis:!0}),r=!0):e instanceof M&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e),source:e.raw})):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),this._warnOrFail(`text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead`,e),i.push({bytes:Qe.encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=i.map(e=>`bytes`in e?e:{bytes:new Uint8Array}),n=this._concatBytes(e.map(e=>e.bytes)),r=this.consumeEncodingIndicator(()=>BigInt(n.length));return new M(n,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednParts:e,...r===void 0?{}:{encodingWidth:r}})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new M(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new R)):o.push(e.bytes);return s(),new R(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value,e);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new R);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value,e);this._mergeFirstBytesItem(t,n)}else if(this._isBytesToken(e.type)){this.t.consume();let n=this._decodeBytesToken(e),r=t[t.length-1];r instanceof M?t[t.length-1]=new M(this._concatBytes([r.value,n])):t.push(new M(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new R(t)}_buildBytesElidedItems(e,t){let n=e.split(`...`),r=[];for(let e=0;e<n.length;e++)e>0&&r.push(new R),n[e].length>0&&r.push(new M(this._hexToBytes(n[e],t)));return r}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof M&&r instanceof M?(e[e.length-1]=new M(this._concatBytes([n.value,r.value])),e.push(...t.slice(1))):e.push(...t)}_concatBytes(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}parseSimple(){this.t.consume(),this.expect(`LPAREN`);let e=this.t.peek();e.type!==`INTEGER`&&this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`,e),this.t.consume();let{numStr:t}=nt(e.value),n=Number(rt(t));return this.expect(`RPAREN`),new L(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`;){if(e.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());e.push(this.parseValue())}this.expect(`GT_GT`);let t;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e)}return new ze(e,{encodingWidth:t})}parseArray(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACKET`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACKET`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`array items must be separated by "," or whitespace`,this.t.peek());i.push(this.parseValue())}this.expect(`RBRACKET`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new F(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseMap(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACE`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACE`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`map entries must be separated by "," or whitespace`,this.t.peek());let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();i.push([e,t])}this.expect(`RBRACE`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new I(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseIndefGroup(){this.t.consume();let e=this.t.peek();if(e.type===`UNDERSCORE`)this.t.consume();else if(e.type===`ENCODING_INDICATOR`&&e.value===`7`)this.t.consume(),this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,e);else if(e.type===`ENCODING_INDICATOR`){let e=this.t.consume(),t=`encoding indicator _${e.value} is not valid in an indefinite string group; use _`;this._warnOrFail(t,e)}else e.type!==`RPAREN`&&this._warnOrFail(`indefinite string group is missing _ after (; interpreting as (_ ...)`,e);let t=this._pendingWarnings.splice(0),n=[];for(;this.t.peek().type!==`RPAREN`;){if(n.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RPAREN`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`indefinite string chunks must be separated by "," or whitespace`,this.t.peek());n.push(this.parseValue())}this.expect(`RPAREN`),n.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let r=n[0];if(r instanceof M){let e=new N(n.map((e,t)=>{if(e instanceof M)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));return t.length>0&&(e.warnings=t),e}if(r instanceof B){let e=new P(n.map((e,t)=>{if(e instanceof B)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));return t.length>0&&(e.warnings=t),e}this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(e){if(this.t.peek().type===`ENCODING_INDICATOR`){let t=this.t.consume(),n=this._resolveEncodingWidth(t.value,t);return n!==void 0&&e!==void 0&&(n=this._validateEncodingFit(e(),n,t)),n}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_applyEiToResult(e,t,n){if(e instanceof A){let r=t===1?`half`:t===2?`single`:t===3?`double`:void 0;if(r===void 0)this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`,n);else if(e.precision!==r){if(r!==`double`){let t=r===`half`?C(S(e.value)):Math.fround(e.value);!Object.is(t,e.value)&&!isNaN(e.value)&&this._warnOrFail(`${e.value} cannot be exactly represented as ${r===`half`?`float16 (_1)`:`float32 (_2)`}`,n)}e.precision=r}}else if(e instanceof O){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.value,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof k){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.argument,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof M){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.value.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof B){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(Qe.encode(e.value).length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof F){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.items.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof I){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.entries.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof j){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.tag,t,n);r!==void 0&&(e.encodingWidth=r)}}else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`,n)}_validateEncodingFit(e,t,n){let r=Ae(t);if(e<=r)return t;let i=`value ${e} does not fit in encoding indicator ${t===`i`?`_i (max 23)`:`_${t} (max ${r})`}`;this._warnOrFail(i,n)}_resolveEncodingWidth(e,t){if(e===`4`||e===`5`||e===`6`){let n=`encoding indicator _${e} (AI ${Number(e)+24}) is reserved and not valid`;this._warnOrFail(n,t);return}if(e===`7`){this._warnOrFail(`indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections`,t);return}return e===`i`?`i`:Number(e)}_extOnError(e){return t=>this._warnOrFail(t,e)}_warnOrFail(e,t){this._warn(e,t),this._options.strict!==!1&&this._fail(e,t)}_hintMissingExtension(e,t){let n=ft.get(e);if(n===void 0||this._hintedPrefixes.has(e))return;this._hintedPrefixes.add(e);let r=`app-string prefix '${e}' requires an extension that is not enabled; ${n}`;this._options.onWarning?this._options.onWarning({message:r,...mt(t)}):this._options.silent||console.warn(`CDN: ${r}`)}_warn(e,t){let n={message:e};if(t!==void 0&&Object.assign(n,mt(t)),this._pendingWarnings.push(n),this._options.onWarning)this._options.onWarning(n);else if(!this._options.silent){let n=t?` at line ${t.line}, column ${t.col}`:``;console.warn(`CDN strict violation${n}: ${e}`)}}_fail(t,n){throw new e.o(t,n?mt(n):void 0)}};function mt(e){return{offset:e.offset,line:e.line,column:e.col,endOffset:e.endOffset}}var ht=new TextEncoder,gt=!1,B=class extends D{indefiniteLength=!1;value;encodingWidth;ednParts;ednSource;ednPartSources;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth,this.ednParts=t?.ednParts,this.ednSource=t?.ednSource,this.ednPartSources=t?.ednPartSources}_encodeTo(e,t){e.writeTextString(3,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(ht.encode(this.value).length)));return _t(this.value,n,e,t,this.ednParts,this.ednSource,this.ednPartSources)}_toJS(e){return this.value}};function _t(e,t,n,r,i,a,o){if(n?.preserveRawString&&a!==void 0)return a+t;let s=n?.preserveRawString?o:void 0,c=s?.some(e=>e!==void 0)??!1,{cdn:l,newline:u}=yt(n),d=f(n),p=n?.preserveConcatenation&&i!==void 0&&(i.length>1||c)?i:void 0;if(d===null)return p===void 0?_e(e)+t:vt(p.map((e,t)=>({text:e,contentDepth:0,source:s?.[t]})),t,null,r);if(!l&&!u&&p===void 0)return _e(e)+t;let m=l?St(e):null;if(p!==void 0&&(m===null||c)){let e=[];for(let[t,n]of p.entries()){let r=s?.[t];if(r!==void 0)e.push({text:n,contentDepth:0,source:r});else if(u){let t=new Map;for(let{point:e,contentDepth:r}of xt(n,0))t.set(e,r);e.push(...At(n,t))}else e.push({text:n,contentDepth:0})}return vt(e,t,d,r)}let h=new Map;if(m!==null)for(let{point:e,contentDepth:t}of m)h.set(e,t);if(u){let t=m===null?xt(e,0):Ct(e);for(let{point:e,contentDepth:n}of t)h.has(e)||h.set(e,n)}let ee=At(e,h);return ee.length<=1?_e(e)+t:vt(ee,t,d,r)}function vt(e,t,n,r){let i=e.map(({text:n,source:r},i)=>{let a=r??_e(n);return i===e.length-1?a+t:a});if(n===null)return i.join(` + `);let a=i[0];for(let t=1;t<i.length;t++){let o=p(n,r+1+e[t].contentDepth);a+=` +\n${o}${i[t]}`}return a}function yt(e){let t=e?.splitCdn===void 0||e?.splitNewline===void 0?bt(e?.textStringFormat??[]):[];return{cdn:e?.splitCdn??t.includes(`cdn`),newline:e?.splitNewline??t.includes(`newline`)}}function bt(e){return e.map(e=>e===`cboredn`?(gt||(gt=!0,console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")),`cdn`):e)}function xt(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
7
+ `&&t.push(n+1);return n=>{let r=Math.max(0,Math.min(e.length,n));r>0&&r===e.length&&r--;let i=0,a=t.length-1;for(;i<=a;){let e=i+a>>1;t[e]<=r?i=e+1:a=e-1}return a+1}}var ut=e=>`import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`,dt=(e,t)=>`install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`,z=e=>`'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`,ft=new Map([[`b32`,ut(`b32`)],[`h32`,ut(`h32`)],[`same`,ut(`same`)],[`hash`,dt(`hash`,`@cbortech/hash-extension`)],[`uuid`,dt(`uuid`,`@cbortech/uuid-extension`)],[`UUID`,dt(`uuid`,`@cbortech/uuid-extension`)],[`dt`,z(`dt`)],[`DT`,z(`dt`)],[`ip`,z(`ip`)],[`IP`,z(`ip`)],[`cri`,z(`cri`)],[`CRI`,z(`cri`)],[`t1`,z(`t1`)],[`b1`,z(`b1`)],[`ilbs`,z(`ilbs`)],[`ilts`,z(`ilts`)],[`float`,z(`float`)]]),pt=class{t;_options;extByPrefix;extByTag;unresolvedExtension;_pendingWarnings=[];_hintedPrefixes=new Set;constructor(t,n){this.t=t,this._options=n,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n.unresolvedExtension??`cpa999`;let r=Z(n.builtinExtensions);for(let e of[...r,...n.extensions??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}this.t.onEscapeWarning=(t,n,r,i,a)=>{let o={message:t,offset:n,line:r,column:i,endOffset:a};if(this._pendingWarnings.push(o),this._options.onWarning?this._options.onWarning(o):this._options.silent||console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`),this._options.strict!==!1)throw new e.o(t,{offset:n,line:r,column:i,endOffset:a})}}parse(){let e=this.parseValue();if(this._options.allowTrailing)return e;let t=this.t.peek();if(t.type!==`EOF`)for(this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`,t),this._pendingWarnings.length>0&&(e.warnings??=[],e.warnings.push(...this._pendingWarnings),this._pendingWarnings=[]);this.t.peek().type!==`EOF`;)this.t.consume();return e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();if(this.t.peek().type===`UNDERSCORE`){let e=this.t.consume();this._warnOrFail(`bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i`,e)}if(this._pendingWarnings.length>0){t.warnings??=[];for(let e of this._pendingWarnings)t.warnings.push(e);this._pendingWarnings=[]}return t.start=e,t.end=this.t.lastEndOffset,t}_parseValueNode(){let e=this.t.peek();switch(e.type){case`INTEGER`:return this.parseIntegerOrTag();case`FLOAT`:return this.parseFloat();case`TSTR`:case`RAWSTRING`:return this.parseString();case`BYTES_HEX`:case`SQSTR`:case`BYTES_B64`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new N([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new P([]);case`TRUE`:return this.t.consume(),new L(21);case`FALSE`:return this.t.consume(),new L(20);case`NULL`:return this.t.consume(),new L(22);case`UNDEFINED`:return this.t.consume(),new L(23);case`SIMPLE`:return this.parseSimple();case`LBRACKET`:return this.parseArray();case`LBRACE`:return this.parseMap();case`LPAREN`:return this.parseIndefGroup();case`LT_LT`:return this.parseEmbeddedCBOR();case`APP_STRING`:{this.t.consume();let t,n=``;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e),n=e.raw}let r=this.extByPrefix.get(e.appPrefix);if(!r?.parseAppString){if(r||this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,[new B(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}{let i=this._pendingWarnings.length;try{let i=r.parseAppString(e.appPrefix,e.value,this._extOnError(e),t===void 0?void 0:{encodingWidth:t});return t!==void 0&&this._applyEiToResult(i,t,e),i instanceof M&&Object.getPrototypeOf(i)===M.prototype&&i.ednSource===void 0?new M(i.value,{ednEncoding:i.ednEncoding,encodingWidth:i.encodingWidth,ednSource:e.raw+n}):(i instanceof A&&i.ednSource===void 0&&(i.ednSource=e.raw+n),i)}catch(t){if(this._options.strict!==!1)throw t;return this._pendingWarnings.length===i&&this._warn(t instanceof Error?t.message:String(t),e),new Ve(e.appPrefix,[new B(e.value)])}}}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`;){if(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),t.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());t.push(this.parseValue())}this.expect(`GT_GT`);let n,r;this.t.peek().type===`ENCODING_INDICATOR`&&(r=this.t.consume(),n=this._resolveEncodingWidth(r.value,r));let i=this.extByPrefix.get(e.appPrefix);if(!i){if(this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}i.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e);{let a=this._pendingWarnings.length;try{let a=i.parseAppSequence(e.appPrefix,t,this._extOnError(e));n!==void 0&&this._applyEiToResult(a,n,r??e);let o=this.t.source.slice(e.offset,this.t.lastEndOffset);if(a instanceof A)a.ednSource===void 0&&(a.ednSource=o);else if(i.preserveAppSeqSource)return new He(a,o);return a}catch(n){if(this._options.strict!==!1)throw n;return this._pendingWarnings.length===a&&this._warn(n instanceof Error?n.message:String(n),e),new Ve(e.appPrefix,t)}}}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new R;let e=[new R];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new R(e)}case`BYTES_HEX_ELIDED`:return this.t.consume(),this._parseHexElidedConcat(e);default:this._fail(`unexpected token: ${JSON.stringify(e.value)}`,e)}}parseIntegerOrTag(){let e=this.t.consume(),{numStr:t,rawSuffix:n}=nt(e.value),r=n===void 0?this.consumeEncodingIndicator():this._resolveEncodingWidth(n,e),i=rt(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Xe(i);if(i<-18446744073709551616n)return new Ze(i);if(r!==void 0){let t=i>=0n?i:-(i+1n);r=this._validateEncodingFit(t,r,e)}let a=i>=0n?new O(i,r===void 0?void 0:{encodingWidth:r}):new k(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof O||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this._pendingWarnings.splice(0),n=this.parseValue();this.expect(`RPAREN`);let i=a.value,o=this.extByTag.get(i);if(o?.parseTag){let e=o.parseTag(i,n);if(e!==void 0)return e instanceof j&&r!==void 0&&e.encodingWidth===void 0&&(e.encodingWidth=r),t.length>0&&(e.warnings??=[],e.warnings.push(...t)),e}let s=new j(i,n,r===void 0?void 0:{encodingWidth:r});return t.length>0&&(s.warnings??=[],s.warnings.push(...t)),s}return a}parseFloat(){let e=this.t.consume(),t=t=>this._warnOrFail(t,e),{value:n,precision:r}=it(e.value,t);if(r===`half`||r===`single`){let e=r===`half`?C(S(n)):Math.fround(n);Object.is(n,e)||isNaN(n)&&isNaN(e)||t(`${n} cannot be exactly represented as ${r===`half`?`f16 (_1)`:`f32 (_2)`}; use _3 or remove the indicator`)}return new A(n,r===void 0?void 0:{precision:r})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(e.value).length));return e.type===`RAWSTRING`?new B(e.value,{ednSource:e.raw,...t===void 0?{}:{encodingWidth:t}}):new B(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();e.type===`ELLIPSIS`?(this.t.consume(),n.push({ellipsis:!0}),t=!0):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),n.push(e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value})):this._isBytesToken(e.type)?(this.t.consume(),n.push({text:this._decodeUtf8(this._decodeBytesToken(e),e)})):this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!t){let e=n.map(e=>`text`in e?e.text:``),t=n.map(e=>`text`in e?e.source:void 0),r=e.join(``),i=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(r).length));return new B(r,{ednParts:e,...t.some(e=>e!==void 0)?{ednPartSources:t}:{},...i===void 0?{}:{encodingWidth:i}})}let r=[],i=[],a=()=>{let e=i.map(e=>e.text),t=e.join(``);if(t!==``){let n=i.map(e=>e.source);r.push(new B(t,{ednParts:e,...n.some(e=>e!==void 0)?{ednPartSources:n}:{}}))}i.length=0};for(let e of n)`ellipsis`in e?(a(),r.push(new R)):i.push(e);return a(),new R(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`}_hexToBytes(t,n){try{return e.a(t)}catch(t){if(t instanceof e.o||!(t instanceof SyntaxError))throw t;this._fail(t.message,n)}}_decodeBytesToken(t){let n=e=>this._warnOrFail(e,t);switch(t.type){case`SQSTR`:{let e=t._sqstrBytes;return e===void 0?this._hexToBytes(t.value,t):e}case`BYTES_HEX`:return this._hexToBytes(t.value,t);case`BYTES_B64`:try{return at(t.value,n)}catch(n){if(n instanceof e.o||!(n instanceof SyntaxError))throw n;this._fail(n.message,t)}default:this._fail(`expected byte string token`,t)}}_decodeUtf8(e,t){if(this._options.allowInvalidUtf8)return et.decode(e);try{return $e.decode(e)}catch{return this._warnOrFail(`byte string in text concatenation is not valid UTF-8`,t),et.decode(e)}}_tokenTypeToCdnEncoding(e){return e===`BYTES_B64`?`base64`:`hex`}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator(()=>BigInt(e.length));return new M(e,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e,source:n}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),i.push({ellipsis:!0}),r=!0;else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let t=this._buildBytesElidedItems(e.value,e);for(let e of t)e instanceof R?(i.push({ellipsis:!0}),r=!0):e instanceof M&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e),source:e.raw})):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),this._warnOrFail(`text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead`,e),i.push({bytes:Qe.encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=i.map(e=>`bytes`in e?e:{bytes:new Uint8Array}),n=this._concatBytes(e.map(e=>e.bytes)),r=this.consumeEncodingIndicator(()=>BigInt(n.length));return new M(n,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednParts:e,...r===void 0?{}:{encodingWidth:r}})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new M(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new R)):o.push(e.bytes);return s(),new R(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value,e);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new R);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value,e);this._mergeFirstBytesItem(t,n)}else if(this._isBytesToken(e.type)){this.t.consume();let n=this._decodeBytesToken(e),r=t[t.length-1];r instanceof M?t[t.length-1]=new M(this._concatBytes([r.value,n])):t.push(new M(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new R(t)}_buildBytesElidedItems(e,t){let n=e.split(`...`),r=[];for(let e=0;e<n.length;e++)e>0&&r.push(new R),n[e].length>0&&r.push(new M(this._hexToBytes(n[e],t)));return r}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof M&&r instanceof M?(e[e.length-1]=new M(this._concatBytes([n.value,r.value])),e.push(...t.slice(1))):e.push(...t)}_concatBytes(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}parseSimple(){this.t.consume(),this.expect(`LPAREN`);let e=this.t.peek();e.type!==`INTEGER`&&this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`,e),this.t.consume();let{numStr:t}=nt(e.value),n=Number(rt(t));return this.expect(`RPAREN`),new L(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`;){if(e.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());e.push(this.parseValue())}this.expect(`GT_GT`);let t;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e)}return new ze(e,{encodingWidth:t})}parseArray(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACKET`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACKET`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`array items must be separated by "," or whitespace`,this.t.peek());i.push(this.parseValue())}this.expect(`RBRACKET`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new F(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseMap(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACE`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACE`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`map entries must be separated by "," or whitespace`,this.t.peek());let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();i.push([e,t])}this.expect(`RBRACE`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new I(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseIndefGroup(){this.t.consume();let e=this.t.peek();if(e.type===`UNDERSCORE`)this.t.consume();else if(e.type===`ENCODING_INDICATOR`&&e.value===`7`)this.t.consume(),this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,e);else if(e.type===`ENCODING_INDICATOR`){let e=this.t.consume(),t=`encoding indicator _${e.value} is not valid in an indefinite string group; use _`;this._warnOrFail(t,e)}else e.type!==`RPAREN`&&this._warnOrFail(`indefinite string group is missing _ after (; interpreting as (_ ...)`,e);let t=this._pendingWarnings.splice(0),n=[];for(;this.t.peek().type!==`RPAREN`;){if(n.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RPAREN`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`indefinite string chunks must be separated by "," or whitespace`,this.t.peek());n.push(this.parseValue())}this.expect(`RPAREN`),n.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let r=n[0];if(r instanceof M){let e=new N(n.map((e,t)=>{if(e instanceof M)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));return t.length>0&&(e.warnings=t),e}if(r instanceof B){let e=new P(n.map((e,t)=>{if(e instanceof B)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));return t.length>0&&(e.warnings=t),e}this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(e){if(this.t.peek().type===`ENCODING_INDICATOR`){let t=this.t.consume(),n=this._resolveEncodingWidth(t.value,t);return n!==void 0&&e!==void 0&&(n=this._validateEncodingFit(e(),n,t)),n}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_applyEiToResult(e,t,n){if(e instanceof A){let r=t===1?`half`:t===2?`single`:t===3?`double`:void 0;if(r===void 0)this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`,n);else if(e.precision!==r){if(r!==`double`){let t=r===`half`?C(S(e.value)):Math.fround(e.value);!Object.is(t,e.value)&&!isNaN(e.value)&&this._warnOrFail(`${e.value} cannot be exactly represented as ${r===`half`?`float16 (_1)`:`float32 (_2)`}`,n)}e.precision=r}}else if(e instanceof O){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.value,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof k){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.argument,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof M){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.value.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof B){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(Qe.encode(e.value).length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof F){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.items.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof I){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.entries.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof j){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.tag,t,n);r!==void 0&&(e.encodingWidth=r)}}else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`,n)}_validateEncodingFit(e,t,n){let r=Ae(t);if(e<=r)return t;let i=`value ${e} does not fit in encoding indicator ${t===`i`?`_i (max 23)`:`_${t} (max ${r})`}`;this._warnOrFail(i,n)}_resolveEncodingWidth(e,t){if(e===`4`||e===`5`||e===`6`){let n=`encoding indicator _${e} (AI ${Number(e)+24}) is reserved and not valid`;this._warnOrFail(n,t);return}if(e===`7`){this._warnOrFail(`indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections`,t);return}return e===`i`?`i`:Number(e)}_extOnError(e){return t=>this._warnOrFail(t,e)}_warnOrFail(e,t){this._warn(e,t),this._options.strict!==!1&&this._fail(e,t)}_hintMissingExtension(e,t){let n=ft.get(e);if(n===void 0||this._hintedPrefixes.has(e))return;this._hintedPrefixes.add(e);let r=`app-string prefix '${e}' requires an extension that is not enabled; ${n}`;this._options.onWarning?this._options.onWarning({message:r,...mt(t),hint:!0}):this._options.silent||console.warn(`CDN: ${r}`)}_warn(e,t){let n={message:e};if(t!==void 0&&Object.assign(n,mt(t)),this._pendingWarnings.push(n),this._options.onWarning)this._options.onWarning(n);else if(!this._options.silent){let n=t?` at line ${t.line}, column ${t.col}`:``;console.warn(`CDN strict violation${n}: ${e}`)}}_fail(t,n){throw new e.o(t,n?mt(n):void 0)}};function mt(e){return{offset:e.offset,line:e.line,column:e.col,endOffset:e.endOffset}}var ht=new TextEncoder,gt=!1,B=class extends D{indefiniteLength=!1;value;encodingWidth;ednParts;ednSource;ednPartSources;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth,this.ednParts=t?.ednParts,this.ednSource=t?.ednSource,this.ednPartSources=t?.ednPartSources}_encodeTo(e,t){e.writeTextString(3,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(ht.encode(this.value).length)));return _t(this.value,n,e,t,this.ednParts,this.ednSource,this.ednPartSources)}_toJS(e){return this.value}};function _t(e,t,n,r,i,a,o){if(n?.preserveRawString&&a!==void 0)return a+t;let s=n?.preserveRawString?o:void 0,c=s?.some(e=>e!==void 0)??!1,{cdn:l,newline:u}=yt(n),d=f(n),p=n?.preserveConcatenation&&i!==void 0&&(i.length>1||c)?i:void 0;if(d===null)return p===void 0?_e(e)+t:vt(p.map((e,t)=>({text:e,contentDepth:0,source:s?.[t]})),t,null,r);if(!l&&!u&&p===void 0)return _e(e)+t;let m=l?St(e):null;if(p!==void 0&&(m===null||c)){let e=[];for(let[t,n]of p.entries()){let r=s?.[t];if(r!==void 0)e.push({text:n,contentDepth:0,source:r});else if(u){let t=new Map;for(let{point:e,contentDepth:r}of xt(n,0))t.set(e,r);e.push(...At(n,t))}else e.push({text:n,contentDepth:0})}return vt(e,t,d,r)}let h=new Map;if(m!==null)for(let{point:e,contentDepth:t}of m)h.set(e,t);if(u){let t=m===null?xt(e,0):Ct(e);for(let{point:e,contentDepth:n}of t)h.has(e)||h.set(e,n)}let ee=At(e,h);return ee.length<=1?_e(e)+t:vt(ee,t,d,r)}function vt(e,t,n,r){let i=e.map(({text:n,source:r},i)=>{let a=r??_e(n);return i===e.length-1?a+t:a});if(n===null)return i.join(` + `);let a=i[0];for(let t=1;t<i.length;t++){let o=p(n,r+1+e[t].contentDepth);a+=` +\n${o}${i[t]}`}return a}function yt(e){let t=e?.splitCdn===void 0||e?.splitNewline===void 0?bt(e?.textStringFormat??[]):[];return{cdn:e?.splitCdn??t.includes(`cdn`),newline:e?.splitNewline??t.includes(`newline`)}}function bt(e){return e.map(e=>e===`cboredn`?(gt||(gt=!0,console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")),`cdn`):e)}function xt(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
8
8
  `?(n.push({point:r+2,contentDepth:t}),r++):n.push({point:r+1,contentDepth:t}):i===`
9
9
  `&&n.push({point:r+1,contentDepth:t})}return n}function St(t){try{tt(t)}catch{return null}let n=[],r=new e.t(t),i=0,a=null,o=!1,s=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;let c=!1;if(o||(o=!0,e.offset>0&&Ot(r.comments,0,e.offset)&&n.push({point:e.offset,contentDepth:i})),a!==null){if(a.kind===`opener`&&Tt.has(e.type)){a.point=e.endOffset,s=e.endOffset;continue}else a.kind===`opener`&&Dt.has(e.type)&&kt(t,a.point,e.offset)?c=!0:n.push({point:e.offset,contentDepth:a.contentDepth});a=null}Et.has(e.type)?(i++,a={point:e.endOffset,contentDepth:i,kind:`opener`}):Dt.has(e.type)?(i=Math.max(0,i-1),c||n.push({point:e.offset,contentDepth:i})):e.type===`COMMA`&&(a={point:e.endOffset,contentDepth:i,kind:`comma`}),s=e.endOffset}let c=r.comments.find(e=>e.start>=s);return c!==void 0&&n.push({point:c.start,contentDepth:i}),n}function Ct(t){let n=[],r=new e.t(t),i=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;if(Et.has(e.type))i++;else if(Dt.has(e.type))i=Math.max(0,i-1);else if(e.type!==`COMMA`){if(e.type===`TSTR`){let r=t.slice(e.offset,e.endOffset);for(let t of wt(r))n.push({point:e.offset+t,contentDepth:i+1})}else if(e.type===`RAWSTRING`){let r=t.slice(e.offset,e.endOffset);for(let{point:t}of xt(r,0))n.push({point:e.offset+t,contentDepth:i+1})}}}return n}function wt(e){let t=[],n=1,r=e.length-1;for(;n<r;){let r=e[n];if(r===`\\`){let r=e[n+1];if(r===`n`||r===`r`)t.push(n+2),n+=2;else if(r===`u`)if(e[n+2]===`{`){let t=e.indexOf(`}`,n+3);n=t>=0?t+1:n+2}else n+=6;else n+=2}else r===`\r`?e[n+1]===`
10
10
  `?(t.push(n+2),n+=2):(t.push(n+1),n++):(r===`
11
- `&&t.push(n+1),n++)}return t}var Tt=new Set([`ENCODING_INDICATOR`,`UNDERSCORE`]),Et=new Set([`LBRACKET`,`LBRACE`,`LPAREN`,`LT_LT`]),Dt=new Set([`RBRACKET`,`RBRACE`,`RPAREN`,`GT_GT`]);function Ot(e,t,n){return e.some(e=>e.start>=t&&e.end<=n)}function kt(e,t,n){return/^[\t\n\r ]*$/.test(e.slice(t,n))}function At(e,t){let n=[...t].filter(([t])=>t>0&&t<e.length).sort(([e],[t])=>e-t);if(n.length===0)return[{text:e,contentDepth:0}];let r=[],i=0,a=0;for(let[t,o]of n)t!==i&&(r.push({text:e.slice(i,t),contentDepth:a}),i=t,a=o);return i<e.length&&r.push({text:e.slice(i),contentDepth:a}),r}function V(e){if(Number.isInteger(e))return new Date(e*1e3).toISOString().replace(/\.000Z$/,`Z`);let t=Math.round(e*1e3);if(t/1e3===e)return new Date(t).toISOString().replace(/\.000Z$/,`Z`);let n=Math.floor(e),r=e-n,i=new Date(n*1e3).toISOString().replace(/\.\d+Z$/,``),a=r.toString(),o=a.indexOf(`.`),s=o>=0?a.slice(o+1):`0`;for(;s.length<3;)s+=`0`;return`${i}.${s}Z`}var jt=new TextDecoder(`utf-8`,{fatal:!0});function Mt(e){if(e.length!==1)throw SyntaxError(`dt<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return jt.decode(t.value);throw SyntaxError(`dt<<...>>: expected a text string or byte string`)}var Nt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;function Pt(e,t){if(!Nt.test(e)){let n=`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;if(t)t(n);else throw SyntaxError(n)}let n=e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i),r,i;n?(r=n[1]+n[3],i=parseFloat(`0`+n[2])):(r=e,i=void 0);let a=Date.parse(r);if(isNaN(a))throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);if(i===void 0){let e=a/1e3;return e>=0?new It(BigInt(e)):new Lt(BigInt(e))}return new Rt(a/1e3+i)}var Ft=1n,It=class extends O{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.value));return`dt'${V(Number(this.value))}'${n}`}},Lt=class extends k{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.argument));return`dt'${V(Number(this.value))}'${n}`}},Rt=class extends A{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=E(this.value),r=ye(this.value,this.precision,n,e?.encodingIndicators??`auto`);return`dt'${V(this.value)}'${r}`}},zt=class extends j{constructor(e,t){super(Ft,typeof e==`string`?Pt(e):e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content;if(n instanceof A?n.precision!==void 0&&n.precision!==E(n.value):n.encodingWidth!==void 0)return super._toCDN({...e,appStrings:!1},t);let r=n instanceof A?n.value:Number(n.value),i=x(e,this.encodingWidth,()=>b(Ft));return`DT'${V(r)}'${i}`}},Bt=class extends zt{constructor(e,t){super(e,t)}_toJS(e){let t=this.content,n=t instanceof A?t.value*1e3:Number(t.value)*1e3;return new Date(n)}};function Vt(e){let t=e?.jsDate??!1;function n(e){return t?new Bt(e):new zt(e)}let r={appStringPrefixes:[`dt`,`DT`],tagNumbers:[Ft],parseAppString(e,t,r){return e===`DT`?n(t):Pt(t,r)},parseAppSequence(e,t,r){let i=Mt(t);return e===`DT`?n(i):Pt(i,r)},parseTag(e,n){if(e!==1n)return;let r;if(n instanceof O)r=new It(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof k)r=new Lt(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof A)r=new Rt(n.value),n.precision!==void 0&&(r.precision=n.precision);else return;return r.start=n.start,r.end=n.end,t?new Bt(r):new zt(r)}};return t&&(r.fromJS=(e,t)=>{if(e instanceof Date)return new Bt(V(e.getTime()/1e3))},r.isJSType=e=>e instanceof Date),r}var Ht=Vt(),Ut=Vt({jsDate:!0});function Wt(e){let t=e.split(`.`);if(t.length!==4)throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);let n=new Uint8Array(4);for(let e=0;e<4;e++){let r=t[e];if(!/^\d+$/.test(r)||r.length>1&&r[0]===`0`)throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);let i=parseInt(r,10);if(i>255)throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);n[e]=i}return n}function Gt(e){let t=new Uint8Array(16);if(e===`::`)return t;let n=e,r=null,i=e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);i&&(n=i[1],n.endsWith(`:`)&&(n+=`:`),r=Wt(i[2]));let a=n.split(`::`);if(a.length>2)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let o=a.length===2,s=a[0]?a[0].split(`:`):[],c=o&&a[1]?a[1].split(`:`):[],l=r?6:8;if(!o&&s.length!==l||o&&s.length+c.length>=l)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let u=l-s.length-c.length,d=[...s,...Array(u).fill(`0`),...c],f=0;for(let e of d){if(!/^[0-9a-fA-F]{1,4}$/.test(e))throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);let n=parseInt(e,16);t[f++]=n>>8&255,t[f++]=n&255}return r&&t.set(r,12),t}function Kt(e){return Array.from(e).join(`.`)}function qt(e){let t=e.slice(0,10).every(e=>e===0)&&e[10]===255&&e[11]===255?Kt(e.slice(12)):null,n=t?6:8,r=[];for(let t=0;t<n*2;t+=2)r.push(e[t]<<8|e[t+1]);let i=-1,a=0,o=0;for(;o<n;)if(r[o]===0){let e=o+1;for(;e<n&&r[e]===0;)e++;e-o>a&&(i=o,a=e-o),o=e}else o++;a<2&&(i=-1);let s=e=>e.toString(16),c;return c=i===-1?r.map(s).join(`:`):`${r.slice(0,i).map(s).join(`:`)}::${r.slice(i+a).map(s).join(`:`)}`,t?`${c}:${t}`:c}var Jt=`ip`,H=`IP`,U=52n,Yt=54n,Xt=new TextDecoder(`utf-8`,{fatal:!0});function Zt(e){if(e.length!==1)throw SyntaxError(`ip<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return Xt.decode(t.value);throw SyntaxError(`ip<<...>>: expected a text string or byte string`)}function Qt(e){return/^\d/.test(e)&&e.includes(`.`)&&!e.includes(`:`)?{bytes:Wt(e),isV4:!0}:{bytes:Gt(e),isV4:!1}}function $t(e){if(e.length===4)return Kt(e);if(e.length===16)return qt(e);throw SyntaxError(`ip: unexpected byte length: ${e.length}`)}function en(e,t){let n=new Uint8Array(e.length);n.set(e);let r=Math.floor(t/8),i=t%8;i>0&&r<e.length&&(n[r]&=255<<8-i&255);for(let t=r+ +(i>0);t<e.length;t++)n[t]=0;let a=Math.ceil(t/8);for(;a>0&&n[a-1]===0;)a--;return n.slice(0,a)}function tn(e,t){let n=new Uint8Array(t);return n.set(e),n}var nn=class extends M{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length)));return`${Jt}'${$t(this.value)}'${n}`}},rn=class extends F{_isV4;constructor(e,t,n){super([new O(BigInt(e)),new M(t)]),this._isV4=n}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=Number(this.items[0].value),r=this.items[1].value;return`${Jt}'${$t(tn(r,this._isV4?4:16))}/${n}'`}},an=class extends j{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.tag===U?4:16,r=this.content;if(r instanceof M){if(r.encodingWidth!==void 0)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.tag));return`${H}'${$t(r.value)}'${n}`}if(r instanceof F&&r.items.length===2&&r.items[0]instanceof O&&r.items[1]instanceof M){if(r.encodingWidth!==void 0||r.items[0].encodingWidth!==void 0||r.items[1].encodingWidth!==void 0)return super._toCDN(e,t);let i=Number(r.items[0].value),a=tn(r.items[1].value,n),o=x(e,this.encodingWidth,()=>b(this.tag));return`${H}'${$t(a)}/${i}'${o}`}return super._toCDN(e,t)}};function on(e,t){let n=t.indexOf(`/`);if(n===-1){let{bytes:n,isV4:r}=Qt(t);return e===H?new an(r?U:Yt,new M(n)):new nn(n)}let r=t.slice(0,n),i=t.slice(n+1);if(!/^\d+$/.test(i))throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);let a=parseInt(i,10),{bytes:o,isV4:s}=Qt(r),c=s?32:128;if(a>c)throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s?`IPv4`:`IPv6`}`);let l=en(o,a);return e===H?new an(s?U:Yt,new F([new O(BigInt(a)),new M(l)])):new rn(a,l,s)}var sn={appStringPrefixes:[Jt,H],tagNumbers:[U,Yt],parseAppString(e,t){return on(e,t)},parseAppSequence(e,t){return on(e,Zt(t))},parseTag(e,t){if(!(e!==U&&e!==Yt)&&(t instanceof M||t instanceof F))return new an(e,t)}},cn=`cri`,ln=`CRI`,un=99n,dn=new Map([[`coap`,-1n],[`coaps`,-2n],[`http`,-3n],[`https`,-4n],[`urn`,-5n],[`did`,-6n],[`coap+tcp`,-7n],[`coaps+tcp`,-8n],[`coap+ws`,-25n],[`coaps+ws`,-26n]]),fn=new Map([...dn.entries()].map(([e,t])=>[t,e]));function W(e){try{return decodeURIComponent(e)}catch{return e}}var pn=new TextEncoder,mn=new TextDecoder(`utf-8`,{fatal:!0});function hn(e){return Array.from(pn.encode(e),e=>`%${e.toString(16).toUpperCase().padStart(2,`0`)}`).join(``)}function G(e,t){let n=``;for(let r of e)n+=t(r)?r:hn(r);return n}function gn(e){return/[A-Za-z0-9\-._~]/.test(e)}function _n(e){return/[!$&'()*+,;=]/.test(e)}function vn(e){return gn(e)||_n(e)||e===`:`||e===`@`}function yn(e){return(vn(e)||e===`/`||e===`?`)&&e!==`&`}function bn(e){return vn(e)||e===`/`||e===`?`}function xn(e){return gn(e)||_n(e)||e===`:`}function Sn(e){return gn(e)||_n(e)}function Cn(e){let t=[],n=e,r=n.indexOf(`@`);r>=0&&(t.push(L.FALSE),t.push(new B(W(n.slice(0,r)))),n=n.slice(r+1));let i,a=null;if(n.startsWith(`[`)){let e=n.indexOf(`]`);if(e<0)throw SyntaxError(`cri: unterminated IPv6 bracket in authority`);i=n.slice(1,e);let r=n.slice(e+1);if(r.startsWith(`:`))a=r.slice(1);else if(r.length>0)throw SyntaxError(`cri: unexpected characters after ']' in authority`);t.push(new M(Gt(i)))}else{let e=n.lastIndexOf(`:`);if(e>=0?(i=n.slice(0,e),a=n.slice(e+1)):i=n,i!==``)if(/^\d{1,3}(\.\d{1,3}){3}$/.test(i))t.push(new M(Wt(i)));else for(let e of i.toLowerCase().split(`.`))t.push(new B(e))}if(a!==null&&a!==``){if(!/^\d+$/.test(a))throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);let e=parseInt(a,10);if(e>65535)throw SyntaxError(`cri: port ${e} out of range`);t.push(new O(BigInt(e)))}return new F(t)}function wn(e){let t=e.items,n=0,r=``;if(n<t.length&&t[n]instanceof L&&t[n].value===20){n++;let e=t[n++];r+=G(e.value,xn)+`@`}if(n>=t.length)return r;let i=t[n];if(i instanceof M){n++;let{length:e}=i.value;if(e===4)r+=Kt(i.value);else if(e===16)r+=`[`+qt(i.value)+`]`;else throw Error(`cri: unexpected host-ip byte length: ${e}`);n<t.length&&t[n]instanceof B&&(r+=`%25${G(t[n++].value,Sn)}`)}else{let e=[];for(;n<t.length&&t[n]instanceof B;)e.push(G(t[n++].value,Sn));r+=e.join(`.`)}return n<t.length&&t[n]instanceof O&&(r+=`:`+t[n].value.toString()),r}function Tn(e){let t=e.slice(2),n=t.indexOf(`/`),r,i;return n>=0?(r=t.slice(0,n),i=t.slice(n+1).split(`/`).map(e=>new B(W(e)))):(r=t,i=[]),{authority:Cn(r),pathSegments:i}}function En(e){let t=e,n=null,r=t.indexOf(`#`);r>=0&&(n=W(t.slice(r+1)),t=t.slice(0,r));let i=null,a=t.indexOf(`?`);if(a>=0){let e=t.slice(a+1);t=t.slice(0,a),i=e.split(`&`).map(e=>new B(W(e)))}let o=[],s=/^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);if(s){let e=s[1].toLowerCase(),t=s[2],n=dn.get(e);if(o.push(n===void 0?new B(e):new k(n)),t.startsWith(`//`)){let{authority:e,pathSegments:n}=Tn(t);o.push(e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new B(W(e)));o.push(L.NULL,new F(e))}else{let e=t.split(`/`).map(e=>new B(W(e)));o.push(L.TRUE,new F(e))}}else if(t.startsWith(`//`)){let{authority:e,pathSegments:n}=Tn(t);o.push(L.FALSE,e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new B(W(e)));o.push(L.TRUE,new F(e))}else if(t===``)o.push(new O(0n));else{let n=1n,r=t,i=!1;for(r.startsWith(`./`)&&(i=!0,r=r.slice(2));r.startsWith(`../`);)n++,r=r.slice(3);if(r===`..`?(n++,r=``):r===`.`&&(r=``),n===1n&&!i&&r!==``&&r.split(`/`)[0].includes(`:`))throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);let a=r===``?[]:r.split(`/`).map(e=>new B(W(e)));o.push(new O(n),new F(a))}if(i!==null&&o.push(new F(i)),n!==null&&(i===null&&o.push(L.NULL),o.push(new B(n))),n!==null&&i===null&&o.splice(o.length-2,1),i===null&&n===null){let e=o[o.length-1];e instanceof F&&e.items.length===0&&o.pop()}return o.length===1&&o[0]instanceof O&&o[0].value===0n?[]:o}function K(e,t){let n=t,r=``;if(n<e.length){let t=e[n];if(t instanceof F){if(n++,t.items.length>0){let e=t.items.map(e=>{if(!(e instanceof B))throw Error(`cri: query item must be a text string`);return G(e.value,yn)});r+=`?`+e.join(`&`)}}else t instanceof L&&t.value===22&&n++}return n<e.length&&e[n]instanceof B&&(r+=`#`+G(e[n].value,bn)),r}function Dn(e){return e.items.map(e=>{if(!(e instanceof B))throw Error(`cri: path segment must be a text string`);return G(e.value,vn)})}function On(e){if(e.length===0)return``;let t=0,n=e[t++];if(n instanceof k||n instanceof B){let r;if(n instanceof k){let e=fn.get(n.value);if(e===void 0)throw Error(`cri: unrecognised scheme-id ${n.value}`);r=e+`:`}else r=n.value+`:`;if(t>=e.length)return r;let i=e[t++],a=``,o=!1;if(i instanceof F)a=`//`+wn(i),o=!0;else if(i instanceof L)if(i.value===22)o=!0;else if(i.value===21)o=!1;else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);else throw Error(`cri: unexpected type for authority element`);let s=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(s=(o?`/`:``)+Dn(n).join(`/`))}return r+a+s+K(e,t)}if(n instanceof L&&n.value===20){if(t>=e.length||!(e[t]instanceof F))throw Error(`cri: network-path reference requires an authority array`);let n=wn(e[t++]),r=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(r=`/`+Dn(n).join(`/`))}return`//`+n+r+K(e,t)}if(n instanceof L&&n.value===21){let n=`/`;if(t<e.length&&e[t]instanceof F){let r=e[t++];n=`/`+Dn(r).join(`/`)}return n+K(e,t)}if(n instanceof O){let r=n.value;if(r===0n)return K(e,t);let i=r===1n?``:`../`.repeat(Number(r)-1),a;if(t<e.length&&e[t]instanceof F){let n=e[t++];if(n.items.length>0){let e=Dn(n);a=(r===1n&&e[0].includes(`:`)?`./`:i)+e.join(`/`)}else a=i===``?`./`:i}else a=i===``?`./`:i;return a+K(e,t)}throw Error(`cri: unrecognised first element type in CRI array`)}var kn=class extends F{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let t=x(e,this.encodingWidth,()=>b(BigInt(this.items.length)));return`${cn}'${On(this.items)}'${t}`}catch{return super._toCDN(e,t)}}},An=class extends j{constructor(e){super(un,e)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let n=this.content;if(n.encodingWidth!==void 0)return super._toCDN(e,t);let r=x(e,this.encodingWidth,()=>b(un));return`${ln}'${On(n.items)}'${r}`}catch{return super._toCDN(e,t)}}};function jn(e){if(e.length!==1)throw SyntaxError(`cri<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return mn.decode(t.value);throw SyntaxError(`cri<<...>>: expected a text string or byte string`)}function Mn(e,t){let n=new kn(En(t));return e===ln?new An(n):n}var Nn={appStringPrefixes:[cn,ln],tagNumbers:[un],parseAppString(e,t){return Mn(e,t)},parseAppSequence(e,t){return Mn(e,jn(t))},parseTag(e,t){if(e!==99n||!(t instanceof F))return;let n=new kn(t.items,{indefiniteLength:t.indefiniteLength,encodingWidth:t.encodingWidth});return n.start=t.start,n.end=t.end,new An(n)}},Pn=18446744073709551615n,Fn=-18446744073709551616n,In={tagNumbers:[We,Ge],parseTag(e,t){if(t instanceof M){if(e===2n){let e=Ye(t.value);return e>Pn?new Xe(e):void 0}if(e===3n){let e=-1n-Ye(t.value);return e<Fn?new Ze(e):void 0}}}};function Ln(e,t){if(e===24&&t<=23n)return 0;if(e===25&&t<=255n)return 1;if(e===26&&t<=65535n)return 2;if(e===27&&t<=4294967295n)return 3}function Rn(e,t){if(e===24&&t<=23)return 0;if(e===25&&t<=255)return 1;if(e===26&&t<=65535)return 2;if(e===27&&t<=4294967295)return 3}var zn=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),Bn=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0});function q(e){throw Error(`CBOR decode error: ${e}`)}function Vn(e,t,n){let r={message:e,offset:t};if(n?.onWarning?n.onWarning(r):n?.silent||console.warn(`CBOR strict violation at offset ${t}: ${e}`),n?.strict!==!1)throw Error(`CBOR decode error: ${e}`);return r}function J(e,t){e.warnings??=[],e.warnings.push(t)}function Y(t){if(t instanceof O)return[`u`,String(t.value)];if(t instanceof k)return[`n`,String(t.value)];if(t instanceof B)return[`t`,t.value];if(t instanceof P)return[`t`,t.chunks.map(e=>e.value).join(``)];if(t instanceof M)return[`b`,e.r(t.value)];if(t instanceof N){let n=``;for(let r of t.chunks)n+=e.r(r.value);return[`b`,n]}if(t instanceof A)return isNaN(t.value)?[`f`,`NaN`]:Object.is(t.value,-0)?[`f`,`-0`]:[`f`,String(t.value)];if(t instanceof L)return[`s`,t.value];if(t instanceof F)return[`A`,t.items.map(Y)];if(t instanceof I){let e=t.entries.map(([e,t])=>[Y(e),Y(t)]);if(e.length<=1)return[`M`,e];let n=e.map(e=>[JSON.stringify(e[0]),e]);return n.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),[`M`,n.map(e=>e[1])]}return t instanceof j?[`G`,String(t.tag),Y(t.content)]:[`c`,e.r(t.toCBOR())]}function Hn(t){if(t instanceof O)return`u`+t.value;if(t instanceof k)return`n`+t.value;if(t instanceof B)return`t`+t.value;if(t instanceof P){let e=`t`;for(let n of t.chunks)e+=n.value;return e}if(t instanceof M)return`b`+e.r(t.value);if(t instanceof N){let n=`b`;for(let r of t.chunks)n+=e.r(r.value);return n}return t instanceof A?isNaN(t.value)?`fNaN`:Object.is(t.value,-0)?`f-0`:`f`+t.value:t instanceof L?`s`+t.value:JSON.stringify(Y(t))}var Un=Array.from({length:24},(e,t)=>BigInt(t)),Wn;function Gn(e){return e===void 0?Wn??=Z(void 0).filter(e=>e.parseTag!==void 0):Z(e).filter(e=>e.parseTag!==void 0)}function Kn(e,t){for(let n=0;n<t;n++)if(e[n]>=128)return;return String.fromCharCode.apply(null,e)}function qn(e,t,n){if(n<=23)return{value:Un[n],nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint8(t)),nextOffset:t+1};case 25:return t+2>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint16(t,!1)),nextOffset:t+2};case 26:return t+4>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint32(t,!1)),nextOffset:t+4};case 27:return t+8>e.byteLength&&q(`unexpected end of input`),{value:e.getBigUint64(t,!1),nextOffset:t+8};default:q(`reserved additional info value: ${n}`)}}function Jn(e,t,n){if(n<=23)return{value:n,nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&q(`unexpected end of input`),{value:e.getUint8(t),nextOffset:t+1};case 25:return t+2>e.byteLength&&q(`unexpected end of input`),{value:e.getUint16(t,!1),nextOffset:t+2};case 26:return t+4>e.byteLength&&q(`unexpected end of input`),{value:e.getUint32(t,!1),nextOffset:t+4};case 27:{t+8>e.byteLength&&q(`unexpected end of input`);let n=e.getUint32(t,!1),r=e.getUint32(t+4,!1);return{value:n*4294967296+r,nextOffset:t+8}}default:q(`reserved additional info value: ${n}`)}}function Yn(e,t,n,r,i,a){let o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite ${i}`),e.getUint8(s)===255){s++;break}let t=X(e,s,n,r);a(t.value)||q(`indefinite-length ${i} chunk must be a definite ${i}`),o.push(t.value),s=t.nextOffset}return{chunks:o,nextOffset:s}}function Xn(e,t,n,r){let i=Hn(e);t.has(i)&&n.push(Vn(`duplicate map key at offset ${e.start}`,e.start,r)),t.add(i)}function X(e,t,n,r){let i=t,a=Qn(e,t,n,r);return a.value.start=i,a.value.end=a.nextOffset,a}function Zn(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n).slice()}function Qn(e,t,n,r){t>=e.byteLength&&q(`unexpected end of input`);let i=e.getUint8(t++),a=i>>5,o=i&31;switch(a){case 0:{let{value:n,nextOffset:r}=qn(e,t,o);return{value:new O(n,{encodingWidth:Ln(o,n)}),nextOffset:r}}case 1:{let{value:n,nextOffset:r}=qn(e,t,o),i=Ln(o,n);return{value:new k(-1n-n,{encodingWidth:i}),nextOffset:r}}case 2:{if(o===31){let{chunks:i,nextOffset:a}=Yn(e,t,n,r,`byte string`,e=>e instanceof M);return{value:new N(i),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i);return a+i>e.byteLength&&q(`byte string extends beyond input`),{value:new M(new Uint8Array(e.buffer,e.byteOffset+a,i).slice(),{encodingWidth:s}),nextOffset:a+i}}case 3:{if(o===31){let{chunks:i,nextOffset:a}=Yn(e,t,n,r,`text string`,e=>e instanceof B);return{value:new P(i),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i);a+i>e.byteLength&&q(`text string extends beyond input`);let c=new Uint8Array(e.buffer,e.byteOffset+a,i),l,u,d=i<64?Kn(c,i):void 0;if(d!==void 0)l=d;else try{l=zn.decode(c)}catch{u=Vn(`invalid UTF-8 sequence in text string`,a,n),l=Bn.decode(c)}let f=new B(l,{encodingWidth:s});return u&&J(f,u),{value:f,nextOffset:a+i}}case 4:{if(o===31){let i=[],a=t;for(;;){if(a>=e.byteLength&&q(`unexpected end of indefinite array`),e.getUint8(a)===255){a++;break}let t=X(e,a,n,r);i.push(t.value),a=t.nextOffset}return{value:new F(i,{indefiniteLength:!0}),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i),c=[],l=a;for(let t=0;t<i;t++){let t=X(e,l,n,r);c.push(t.value),l=t.nextOffset}return{value:new F(c,{encodingWidth:s}),nextOffset:l}}case 5:{if(o===31){let i=[],a=new Set,o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite map`),e.getUint8(s)===255){s++;break}let t=X(e,s,n,r);Xn(t.value,a,o,n),s=t.nextOffset;let c=X(e,s,n,r);s=c.nextOffset,i.push([t.value,c.value])}let c=new I(i,{indefiniteLength:!0});for(let e of o)J(c,e);return{value:c,nextOffset:s}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i),c=[],l=new Set,u=[],d=a;for(let t=0;t<i;t++){let t=X(e,d,n,r);Xn(t.value,l,u,n),d=t.nextOffset;let i=X(e,d,n,r);d=i.nextOffset,c.push([t.value,i.value])}let f=new I(c,{encodingWidth:s});for(let e of u)J(f,e);return{value:f,nextOffset:d}}case 6:{o===31&&q(`tags cannot use indefinite-length encoding`);let{value:i,nextOffset:a}=qn(e,t,o),s=Ln(o,i),c=X(e,a,n,r);for(let e of r){let t=e.parseTag(i,c.value,n);if(t!==void 0)return t instanceof j&&s!==void 0&&(t.encodingWidth=s),{value:t,nextOffset:c.nextOffset}}return{value:new j(i,c.value,{encodingWidth:s}),nextOffset:c.nextOffset}}case 7:if(o<=19)return{value:new L(o),nextOffset:t};if(o===20)return{value:new L(20),nextOffset:t};if(o===21)return{value:new L(21),nextOffset:t};if(o===22)return{value:new L(22),nextOffset:t};if(o===23)return{value:new L(23),nextOffset:t};if(o===24){t+1>e.byteLength&&q(`unexpected end of input`);let r=e.getUint8(t);if(r<32){let e=Vn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`,t-1,n),i=new L(r);return J(i,e),{value:i,nextOffset:t+1}}return{value:new L(r),nextOffset:t+1}}if(o===25){t+2>e.byteLength&&q(`unexpected end of input`);let n=C(e.getUint16(t,!1));return{value:new A(n,{precision:`half`,rawBits:Number.isNaN(n)?Zn(e,t,2):void 0}),nextOffset:t+2}}if(o===26){t+4>e.byteLength&&q(`unexpected end of input`);let n=e.getFloat32(t,!1);return{value:new A(n,{precision:`single`,rawBits:Number.isNaN(n)?Zn(e,t,4):void 0}),nextOffset:t+4}}if(o===27){t+8>e.byteLength&&q(`unexpected end of input`);let n=e.getFloat64(t,!1);return{value:new A(n,{precision:`double`,rawBits:Number.isNaN(n)?Zn(e,t,8):void 0}),nextOffset:t+8}}return o<31&&q(`reserved additional info value in major type 7: ${o}`),q(`unexpected break code outside indefinite-length item`)}return q(`unknown major type: ${a}`)}function $n(e){if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`expected ArrayBufferView or ArrayBufferLike`)}function er(e,t){let n=$n(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=t?.offset??0;if(!Number.isInteger(i)||i<0||i>r.byteLength)throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);let a=Gn(t?.builtinExtensions),o=t?.extensions?.length?[...t.extensions.filter(e=>e.parseTag!==void 0),...a]:a,{value:s,nextOffset:c}=X(r,i,t,o);if(!t?.allowTrailing&&c!==r.byteLength){J(s,Vn(`${r.byteLength-c} trailing byte(s) after end of CBOR item`,c,t));let e={strict:!1,silent:!0},n=c;for(;n<r.byteLength;)({nextOffset:n}=X(r,n,e,o))}return s}var tr=24n,nr={tagNumbers:[tr],parseTag(e,t,n){if(e!==24n||!(t instanceof M))return;let r=n?{extensions:n.extensions,builtinExtensions:n.builtinExtensions,strict:n.strict,onWarning:n.onWarning,silent:n.silent}:void 0;try{return new j(tr,new ze([er(t.value,r)],{encodingWidth:t.encodingWidth}))}catch(e){if(r?.strict!==!1)throw e;return}}};function rr(e){return e instanceof R&&!(e.content instanceof F)}function ir(e){let t=!1,n=!1,r=!1,i;for(let a of e){let e;if(rr(a))e=!0,r=!0;else if(a instanceof B)e=!1,t=!0;else if(a instanceof M)e=!1,n=!0;else return!1;if(e===i)return!1;i=e}return r&&!(t&&n)}var ar={tagNumbers:[Ue],parseTag(e,t){if(e===888n){if(t instanceof L&&t.value===22)return new R;if(t instanceof F&&ir(t.items))return new R(t.items)}}},or=new TextEncoder,sr=new TextDecoder(`utf-8`,{fatal:!0}),cr=new TextDecoder(`utf-8`,{fatal:!1}),lr=Symbol(`ellipsis`);function ur(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function dr(e,t,n){if(t instanceof He){dr(e,t.inner,n);return}if(t instanceof R){if(t.content instanceof F)for(let r of t.content.items)dr(e,r,n);else n.push(lr);return}if(t instanceof B){n.push(or.encode(t.value));return}if(t instanceof M){n.push(t.value);return}if(t instanceof P){n.push(or.encode(t.chunks.map(e=>e.value).join(``)));return}if(t instanceof N){n.push(ur(t.chunks.map(e=>e.value)));return}throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`)}function fr(e,t){try{return sr.decode(e)}catch{let n=`t1 concatenation result is not valid UTF-8`;if(t)t(n);else throw SyntaxError(n);return cr.decode(e)}}function pr(e,t,n){let r=[];for(let n of t)dr(e,n,r);let i=e===`t1`,a=[],o=!1,s=[],c=()=>{if(s.length===0)return;let e=ur(s);s.length=0,e.length!==0&&a.push(i?new B(fr(e,n)):new M(e))};for(let e of r)e===lr?(c(),a[a.length-1]instanceof R||(a.push(new R),o=!0)):s.push(e);if(!o){let e=ur(s);return i?new B(fr(e,n)):new M(e)}return c(),a.length===1?new R:new R(a)}function mr(e){return{appStringPrefixes:[e],preserveAppSeqSource:!0,parseAppString(t,n,r){return pr(e,[new B(n)],r)},parseAppSequence(t,n,r){return pr(e,n,r)}}}var hr=mr(`t1`),gr=mr(`b1`),_r=new TextEncoder,vr=new TextDecoder(`utf-8`,{fatal:!0}),yr=new TextDecoder(`utf-8`,{fatal:!1});function br(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function xr(e,t,n){let r=e===`ilts`,i=[],a=[];for(let o of t){if(o instanceof He&&(o=o.inner),o instanceof R)throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);let t,s,c;if(o instanceof B)t=o.value,c=o.encodingWidth;else if(o instanceof M)s=o.value,c=o.encodingWidth;else if(o instanceof P)t=o.chunks.map(e=>e.value).join(``);else if(o instanceof N)s=br(o.chunks.map(e=>e.value));else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);if(r){let e;if(t!==void 0)e=t;else try{e=vr.decode(s)}catch{let t=`ilts chunk is not valid UTF-8`;if(n)n(t);else throw SyntaxError(t);e=yr.decode(s)}a.push(new B(e,c===void 0?void 0:{encodingWidth:c}))}else{let e=s??_r.encode(t);i.push(new M(e,c===void 0?void 0:{encodingWidth:c}))}}return r?new P(a):new N(i)}function Sr(e){return{appStringPrefixes:[e],preserveAppSeqSource:!0,parseAppString(t,n,r){return new He(xr(e,[new B(n)],r),`${e}${ge(n)}`)},parseAppSequence(t,n,r){return xr(e,n,r)}}}var Cr=Sr(`ilbs`),wr=Sr(`ilts`);function Tr(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===`
11
+ `&&t.push(n+1),n++)}return t}var Tt=new Set([`ENCODING_INDICATOR`,`UNDERSCORE`]),Et=new Set([`LBRACKET`,`LBRACE`,`LPAREN`,`LT_LT`]),Dt=new Set([`RBRACKET`,`RBRACE`,`RPAREN`,`GT_GT`]);function Ot(e,t,n){return e.some(e=>e.start>=t&&e.end<=n)}function kt(e,t,n){return/^[\t\n\r ]*$/.test(e.slice(t,n))}function At(e,t){let n=[...t].filter(([t])=>t>0&&t<e.length).sort(([e],[t])=>e-t);if(n.length===0)return[{text:e,contentDepth:0}];let r=[],i=0,a=0;for(let[t,o]of n)t!==i&&(r.push({text:e.slice(i,t),contentDepth:a}),i=t,a=o);return i<e.length&&r.push({text:e.slice(i),contentDepth:a}),r}function V(e){if(Number.isInteger(e))return new Date(e*1e3).toISOString().replace(/\.000Z$/,`Z`);let t=Math.round(e*1e3);if(t/1e3===e)return new Date(t).toISOString().replace(/\.000Z$/,`Z`);let n=Math.floor(e),r=e-n,i=new Date(n*1e3).toISOString().replace(/\.\d+Z$/,``),a=r.toString(),o=a.indexOf(`.`),s=o>=0?a.slice(o+1):`0`;for(;s.length<3;)s+=`0`;return`${i}.${s}Z`}var jt=new TextDecoder(`utf-8`,{fatal:!0});function Mt(e){if(e.length!==1)throw SyntaxError(`dt<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return jt.decode(t.value);throw SyntaxError(`dt<<...>>: expected a text string or byte string`)}var Nt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;function Pt(e,t){if(!Nt.test(e)){let n=`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;if(t)t(n);else throw SyntaxError(n)}let n=e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i),r,i;n?(r=n[1]+n[3],i=parseFloat(`0`+n[2])):(r=e,i=void 0);let a=Date.parse(r);if(isNaN(a))throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);if(i===void 0){let e=a/1e3;return e>=0?new It(BigInt(e)):new Lt(BigInt(e))}return new Rt(a/1e3+i)}var Ft=1n,It=class extends O{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.value));return`dt'${V(Number(this.value))}'${n}`}},Lt=class extends k{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.argument));return`dt'${V(Number(this.value))}'${n}`}},Rt=class extends A{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=E(this.value),r=ye(this.value,this.precision,n,e?.encodingIndicators??`auto`);return`dt'${V(this.value)}'${r}`}},zt=class extends j{constructor(e,t){super(Ft,typeof e==`string`?Pt(e):e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content;if(n instanceof A?n.precision!==void 0&&n.precision!==E(n.value):n.encodingWidth!==void 0)return super._toCDN({...e,appStrings:!1},t);let r=n instanceof A?n.value:Number(n.value),i=x(e,this.encodingWidth,()=>b(Ft));return`DT'${V(r)}'${i}`}},Bt=class extends zt{constructor(e,t){super(e,t)}_toJS(e){let t=this.content,n=t instanceof A?t.value*1e3:Number(t.value)*1e3;return new Date(n)}};function Vt(e){let t=e?.jsDate??!1;function n(e){return t?new Bt(e):new zt(e)}let r={appStringPrefixes:[`dt`,`DT`],tagNumbers:[Ft],parseAppString(e,t,r){return e===`DT`?n(t):Pt(t,r)},parseAppSequence(e,t,r){let i=Mt(t);return e===`DT`?n(i):Pt(i,r)},parseTag(e,n){if(e!==1n)return;let r;if(n instanceof O)r=new It(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof k)r=new Lt(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof A)r=new Rt(n.value),n.precision!==void 0&&(r.precision=n.precision);else return;return r.start=n.start,r.end=n.end,t?new Bt(r):new zt(r)}};return t&&(r.fromJS=(e,t)=>{if(e instanceof Date)return new Bt(V(e.getTime()/1e3))},r.isJSType=e=>e instanceof Date),r}var Ht=Vt(),Ut=Vt({jsDate:!0});function Wt(e){let t=e.split(`.`);if(t.length!==4)throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);let n=new Uint8Array(4);for(let e=0;e<4;e++){let r=t[e];if(!/^\d+$/.test(r)||r.length>1&&r[0]===`0`)throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);let i=parseInt(r,10);if(i>255)throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);n[e]=i}return n}function Gt(e){let t=new Uint8Array(16);if(e===`::`)return t;let n=e,r=null,i=e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);i&&(n=i[1],n.endsWith(`:`)&&(n+=`:`),r=Wt(i[2]));let a=n.split(`::`);if(a.length>2)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let o=a.length===2,s=a[0]?a[0].split(`:`):[],c=o&&a[1]?a[1].split(`:`):[],l=r?6:8;if(!o&&s.length!==l||o&&s.length+c.length>=l)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let u=l-s.length-c.length,d=[...s,...Array(u).fill(`0`),...c],f=0;for(let e of d){if(!/^[0-9a-fA-F]{1,4}$/.test(e))throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);let n=parseInt(e,16);t[f++]=n>>8&255,t[f++]=n&255}return r&&t.set(r,12),t}function Kt(e){return Array.from(e).join(`.`)}function qt(e){let t=e.slice(0,10).every(e=>e===0)&&e[10]===255&&e[11]===255?Kt(e.slice(12)):null,n=t?6:8,r=[];for(let t=0;t<n*2;t+=2)r.push(e[t]<<8|e[t+1]);let i=-1,a=0,o=0;for(;o<n;)if(r[o]===0){let e=o+1;for(;e<n&&r[e]===0;)e++;e-o>a&&(i=o,a=e-o),o=e}else o++;a<2&&(i=-1);let s=e=>e.toString(16),c;return c=i===-1?r.map(s).join(`:`):`${r.slice(0,i).map(s).join(`:`)}::${r.slice(i+a).map(s).join(`:`)}`,t?`${c}:${t}`:c}var Jt=`ip`,H=`IP`,U=52n,Yt=54n,Xt=new TextDecoder(`utf-8`,{fatal:!0});function Zt(e){if(e.length!==1)throw SyntaxError(`ip<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return Xt.decode(t.value);throw SyntaxError(`ip<<...>>: expected a text string or byte string`)}function Qt(e){return/^\d/.test(e)&&e.includes(`.`)&&!e.includes(`:`)?{bytes:Wt(e),isV4:!0}:{bytes:Gt(e),isV4:!1}}function $t(e){if(e.length===4)return Kt(e);if(e.length===16)return qt(e);throw SyntaxError(`ip: unexpected byte length: ${e.length}`)}function en(e,t){let n=new Uint8Array(e.length);n.set(e);let r=Math.floor(t/8),i=t%8;i>0&&r<e.length&&(n[r]&=255<<8-i&255);for(let t=r+ +(i>0);t<e.length;t++)n[t]=0;let a=Math.ceil(t/8);for(;a>0&&n[a-1]===0;)a--;return n.slice(0,a)}function tn(e,t){let n=new Uint8Array(t);return n.set(e),n}var nn=class extends M{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length)));return`${Jt}'${$t(this.value)}'${n}`}},rn=class extends F{_isV4;constructor(e,t,n){super([new O(BigInt(e)),new M(t)]),this._isV4=n}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=Number(this.items[0].value),r=this.items[1].value;return`${Jt}'${$t(tn(r,this._isV4?4:16))}/${n}'`}},an=class extends j{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.tag===U?4:16,r=this.content;if(r instanceof M){if(r.encodingWidth!==void 0)return super._toCDN(e,t);let n=x(e,this.encodingWidth,()=>b(this.tag));return`${H}'${$t(r.value)}'${n}`}if(r instanceof F&&r.items.length===2&&r.items[0]instanceof O&&r.items[1]instanceof M){if(r.encodingWidth!==void 0||r.items[0].encodingWidth!==void 0||r.items[1].encodingWidth!==void 0)return super._toCDN(e,t);let i=Number(r.items[0].value),a=tn(r.items[1].value,n),o=x(e,this.encodingWidth,()=>b(this.tag));return`${H}'${$t(a)}/${i}'${o}`}return super._toCDN(e,t)}};function on(e,t){let n=t.indexOf(`/`);if(n===-1){let{bytes:n,isV4:r}=Qt(t);return e===H?new an(r?U:Yt,new M(n)):new nn(n)}let r=t.slice(0,n),i=t.slice(n+1);if(!/^\d+$/.test(i))throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);let a=parseInt(i,10),{bytes:o,isV4:s}=Qt(r),c=s?32:128;if(a>c)throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s?`IPv4`:`IPv6`}`);let l=en(o,a);return e===H?new an(s?U:Yt,new F([new O(BigInt(a)),new M(l)])):new rn(a,l,s)}var sn={appStringPrefixes:[Jt,H],tagNumbers:[U,Yt],parseAppString(e,t){return on(e,t)},parseAppSequence(e,t){return on(e,Zt(t))},parseTag(e,t){if(!(e!==U&&e!==Yt)&&(t instanceof M||t instanceof F))return new an(e,t)}},cn=`cri`,ln=`CRI`,un=99n,dn=new Map([[`coap`,-1n],[`coaps`,-2n],[`http`,-3n],[`https`,-4n],[`urn`,-5n],[`did`,-6n],[`coap+tcp`,-7n],[`coaps+tcp`,-8n],[`coap+ws`,-25n],[`coaps+ws`,-26n]]),fn=new Map([...dn.entries()].map(([e,t])=>[t,e]));function W(e){try{return decodeURIComponent(e)}catch{return e}}var pn=new TextEncoder,mn=new TextDecoder(`utf-8`,{fatal:!0});function hn(e){return Array.from(pn.encode(e),e=>`%${e.toString(16).toUpperCase().padStart(2,`0`)}`).join(``)}function G(e,t){let n=``;for(let r of e)n+=t(r)?r:hn(r);return n}function gn(e){return/[A-Za-z0-9\-._~]/.test(e)}function _n(e){return/[!$&'()*+,;=]/.test(e)}function vn(e){return gn(e)||_n(e)||e===`:`||e===`@`}function yn(e){return(vn(e)||e===`/`||e===`?`)&&e!==`&`}function bn(e){return vn(e)||e===`/`||e===`?`}function xn(e){return gn(e)||_n(e)||e===`:`}function Sn(e){return gn(e)||_n(e)}function Cn(e){let t=[],n=e,r=n.indexOf(`@`);r>=0&&(t.push(L.FALSE),t.push(new B(W(n.slice(0,r)))),n=n.slice(r+1));let i,a=null;if(n.startsWith(`[`)){let e=n.indexOf(`]`);if(e<0)throw SyntaxError(`cri: unterminated IPv6 bracket in authority`);i=n.slice(1,e);let r=n.slice(e+1);if(r.startsWith(`:`))a=r.slice(1);else if(r.length>0)throw SyntaxError(`cri: unexpected characters after ']' in authority`);t.push(new M(Gt(i)))}else{let e=n.lastIndexOf(`:`);if(e>=0?(i=n.slice(0,e),a=n.slice(e+1)):i=n,i!==``)if(/^\d{1,3}(\.\d{1,3}){3}$/.test(i))t.push(new M(Wt(i)));else for(let e of i.toLowerCase().split(`.`))t.push(new B(e))}if(a!==null&&a!==``){if(!/^\d+$/.test(a))throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);let e=parseInt(a,10);if(e>65535)throw SyntaxError(`cri: port ${e} out of range`);t.push(new O(BigInt(e)))}return new F(t)}function wn(e){let t=e.items,n=0,r=``;if(n<t.length&&t[n]instanceof L&&t[n].value===20){n++;let e=t[n++];r+=G(e.value,xn)+`@`}if(n>=t.length)return r;let i=t[n];if(i instanceof M){n++;let{length:e}=i.value;if(e===4)r+=Kt(i.value);else if(e===16)r+=`[`+qt(i.value)+`]`;else throw Error(`cri: unexpected host-ip byte length: ${e}`);n<t.length&&t[n]instanceof B&&(r+=`%25${G(t[n++].value,Sn)}`)}else{let e=[];for(;n<t.length&&t[n]instanceof B;)e.push(G(t[n++].value,Sn));r+=e.join(`.`)}return n<t.length&&t[n]instanceof O&&(r+=`:`+t[n].value.toString()),r}function Tn(e){let t=e.slice(2),n=t.indexOf(`/`),r,i;return n>=0?(r=t.slice(0,n),i=t.slice(n+1).split(`/`).map(e=>new B(W(e)))):(r=t,i=[]),{authority:Cn(r),pathSegments:i}}function En(e){let t=e,n=null,r=t.indexOf(`#`);r>=0&&(n=W(t.slice(r+1)),t=t.slice(0,r));let i=null,a=t.indexOf(`?`);if(a>=0){let e=t.slice(a+1);t=t.slice(0,a),i=e.split(`&`).map(e=>new B(W(e)))}let o=[],s=/^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);if(s){let e=s[1].toLowerCase(),t=s[2],n=dn.get(e);if(o.push(n===void 0?new B(e):new k(n)),t.startsWith(`//`)){let{authority:e,pathSegments:n}=Tn(t);o.push(e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new B(W(e)));o.push(L.NULL,new F(e))}else{let e=t.split(`/`).map(e=>new B(W(e)));o.push(L.TRUE,new F(e))}}else if(t.startsWith(`//`)){let{authority:e,pathSegments:n}=Tn(t);o.push(L.FALSE,e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new B(W(e)));o.push(L.TRUE,new F(e))}else if(t===``)o.push(new O(0n));else{let n=1n,r=t,i=!1;for(r.startsWith(`./`)&&(i=!0,r=r.slice(2));r.startsWith(`../`);)n++,r=r.slice(3);if(r===`..`?(n++,r=``):r===`.`&&(r=``),n===1n&&!i&&r!==``&&r.split(`/`)[0].includes(`:`))throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);let a=r===``?[]:r.split(`/`).map(e=>new B(W(e)));o.push(new O(n),new F(a))}if(i!==null&&o.push(new F(i)),n!==null&&(i===null&&o.push(L.NULL),o.push(new B(n))),n!==null&&i===null&&o.splice(o.length-2,1),i===null&&n===null){let e=o[o.length-1];e instanceof F&&e.items.length===0&&o.pop()}return o.length===1&&o[0]instanceof O&&o[0].value===0n?[]:o}function K(e,t){let n=t,r=``;if(n<e.length){let t=e[n];if(t instanceof F){if(n++,t.items.length>0){let e=t.items.map(e=>{if(!(e instanceof B))throw Error(`cri: query item must be a text string`);return G(e.value,yn)});r+=`?`+e.join(`&`)}}else t instanceof L&&t.value===22&&n++}return n<e.length&&e[n]instanceof B&&(r+=`#`+G(e[n].value,bn)),r}function Dn(e){return e.items.map(e=>{if(!(e instanceof B))throw Error(`cri: path segment must be a text string`);return G(e.value,vn)})}function On(e){if(e.length===0)return``;let t=0,n=e[t++];if(n instanceof k||n instanceof B){let r;if(n instanceof k){let e=fn.get(n.value);if(e===void 0)throw Error(`cri: unrecognised scheme-id ${n.value}`);r=e+`:`}else r=n.value+`:`;if(t>=e.length)return r;let i=e[t++],a=``,o=!1;if(i instanceof F)a=`//`+wn(i),o=!0;else if(i instanceof L)if(i.value===22)o=!0;else if(i.value===21)o=!1;else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);else throw Error(`cri: unexpected type for authority element`);let s=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(s=(o?`/`:``)+Dn(n).join(`/`))}return r+a+s+K(e,t)}if(n instanceof L&&n.value===20){if(t>=e.length||!(e[t]instanceof F))throw Error(`cri: network-path reference requires an authority array`);let n=wn(e[t++]),r=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(r=`/`+Dn(n).join(`/`))}return`//`+n+r+K(e,t)}if(n instanceof L&&n.value===21){let n=`/`;if(t<e.length&&e[t]instanceof F){let r=e[t++];n=`/`+Dn(r).join(`/`)}return n+K(e,t)}if(n instanceof O){let r=n.value;if(r===0n)return K(e,t);let i=r===1n?``:`../`.repeat(Number(r)-1),a;if(t<e.length&&e[t]instanceof F){let n=e[t++];if(n.items.length>0){let e=Dn(n);a=(r===1n&&e[0].includes(`:`)?`./`:i)+e.join(`/`)}else a=i===``?`./`:i}else a=i===``?`./`:i;return a+K(e,t)}throw Error(`cri: unrecognised first element type in CRI array`)}var kn=class extends F{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let t=x(e,this.encodingWidth,()=>b(BigInt(this.items.length)));return`${cn}'${On(this.items)}'${t}`}catch{return super._toCDN(e,t)}}},An=class extends j{constructor(e){super(un,e)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let n=this.content;if(n.encodingWidth!==void 0)return super._toCDN(e,t);let r=x(e,this.encodingWidth,()=>b(un));return`${ln}'${On(n.items)}'${r}`}catch{return super._toCDN(e,t)}}};function jn(e){if(e.length!==1)throw SyntaxError(`cri<<...>>: expected exactly one item`);let t=e[0];if(t instanceof B)return t.value;if(t instanceof M)return mn.decode(t.value);throw SyntaxError(`cri<<...>>: expected a text string or byte string`)}function Mn(e,t){let n=new kn(En(t));return e===ln?new An(n):n}var Nn={appStringPrefixes:[cn,ln],tagNumbers:[un],parseAppString(e,t){return Mn(e,t)},parseAppSequence(e,t){return Mn(e,jn(t))},parseTag(e,t){if(e!==99n||!(t instanceof F))return;let n=new kn(t.items,{indefiniteLength:t.indefiniteLength,encodingWidth:t.encodingWidth});return n.start=t.start,n.end=t.end,new An(n)}},Pn=18446744073709551615n,Fn=-18446744073709551616n,In={tagNumbers:[We,Ge],parseTag(e,t){if(t instanceof M){if(e===2n){let e=Ye(t.value);return e>Pn?new Xe(e):void 0}if(e===3n){let e=-1n-Ye(t.value);return e<Fn?new Ze(e):void 0}}}};function Ln(e,t){if(e===24&&t<=23n)return 0;if(e===25&&t<=255n)return 1;if(e===26&&t<=65535n)return 2;if(e===27&&t<=4294967295n)return 3}function Rn(e,t){if(e===24&&t<=23)return 0;if(e===25&&t<=255)return 1;if(e===26&&t<=65535)return 2;if(e===27&&t<=4294967295)return 3}var zn=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),Bn=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0});function q(e){throw Error(`CBOR decode error: ${e}`)}function Vn(e,t,n){let r={message:e,offset:t};if(n?.onWarning?n.onWarning(r):n?.silent||console.warn(`CBOR strict violation at offset ${t}: ${e}`),n?.strict!==!1)throw Error(`CBOR decode error: ${e}`);return r}function J(e,t){e.warnings??=[],e.warnings.push(t)}function Y(t){if(t instanceof O)return[`u`,String(t.value)];if(t instanceof k)return[`n`,String(t.value)];if(t instanceof B)return[`t`,t.value];if(t instanceof P)return[`t`,t.chunks.map(e=>e.value).join(``)];if(t instanceof M)return[`b`,e.r(t.value)];if(t instanceof N){let n=``;for(let r of t.chunks)n+=e.r(r.value);return[`b`,n]}if(t instanceof A)return isNaN(t.value)?[`f`,`NaN`]:Object.is(t.value,-0)?[`f`,`-0`]:[`f`,String(t.value)];if(t instanceof L)return[`s`,t.value];if(t instanceof F)return[`A`,t.items.map(Y)];if(t instanceof I){let e=t.entries.map(([e,t])=>[Y(e),Y(t)]);if(e.length<=1)return[`M`,e];let n=e.map(e=>[JSON.stringify(e[0]),e]);return n.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),[`M`,n.map(e=>e[1])]}return t instanceof j?[`G`,String(t.tag),Y(t.content)]:[`c`,e.r(t.toCBOR())]}function Hn(t){if(t instanceof O)return`u`+t.value;if(t instanceof k)return`n`+t.value;if(t instanceof B)return`t`+t.value;if(t instanceof P){let e=`t`;for(let n of t.chunks)e+=n.value;return e}if(t instanceof M)return`b`+e.r(t.value);if(t instanceof N){let n=`b`;for(let r of t.chunks)n+=e.r(r.value);return n}return t instanceof A?isNaN(t.value)?`fNaN`:Object.is(t.value,-0)?`f-0`:`f`+t.value:t instanceof L?`s`+t.value:JSON.stringify(Y(t))}var Un=Array.from({length:24},(e,t)=>BigInt(t)),Wn;function Gn(e){return e===void 0?Wn??=Z(void 0).filter(e=>e.parseTag!==void 0):Z(e).filter(e=>e.parseTag!==void 0)}function Kn(e,t){for(let n=0;n<t;n++)if(e[n]>=128)return;return String.fromCharCode.apply(null,e)}function qn(e,t,n){if(n<=23)return{value:Un[n],nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint8(t)),nextOffset:t+1};case 25:return t+2>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint16(t,!1)),nextOffset:t+2};case 26:return t+4>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint32(t,!1)),nextOffset:t+4};case 27:return t+8>e.byteLength&&q(`unexpected end of input`),{value:e.getBigUint64(t,!1),nextOffset:t+8};default:q(`reserved additional info value: ${n}`)}}function Jn(e,t,n){if(n<=23)return{value:n,nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&q(`unexpected end of input`),{value:e.getUint8(t),nextOffset:t+1};case 25:return t+2>e.byteLength&&q(`unexpected end of input`),{value:e.getUint16(t,!1),nextOffset:t+2};case 26:return t+4>e.byteLength&&q(`unexpected end of input`),{value:e.getUint32(t,!1),nextOffset:t+4};case 27:{t+8>e.byteLength&&q(`unexpected end of input`);let n=e.getUint32(t,!1),r=e.getUint32(t+4,!1);return{value:n*4294967296+r,nextOffset:t+8}}default:q(`reserved additional info value: ${n}`)}}function Yn(e,t,n,r,i,a){let o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite ${i}`),e.getUint8(s)===255){s++;break}let t=X(e,s,n,r);a(t.value)||q(`indefinite-length ${i} chunk must be a definite ${i}`),o.push(t.value),s=t.nextOffset}return{chunks:o,nextOffset:s}}function Xn(e,t,n,r){let i=Hn(e);t.has(i)&&n.push(Vn(`duplicate map key at offset ${e.start}`,e.start,r)),t.add(i)}function X(e,t,n,r){let i=t,a=Qn(e,t,n,r);return a.value.start=i,a.value.end=a.nextOffset,a}function Zn(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n).slice()}function Qn(e,t,n,r){t>=e.byteLength&&q(`unexpected end of input`);let i=e.getUint8(t++),a=i>>5,o=i&31;switch(a){case 0:{let{value:n,nextOffset:r}=qn(e,t,o);return{value:new O(n,{encodingWidth:Ln(o,n)}),nextOffset:r}}case 1:{let{value:n,nextOffset:r}=qn(e,t,o),i=Ln(o,n);return{value:new k(-1n-n,{encodingWidth:i}),nextOffset:r}}case 2:{if(o===31){let{chunks:i,nextOffset:a}=Yn(e,t,n,r,`byte string`,e=>e instanceof M);return{value:new N(i),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i);return a+i>e.byteLength&&q(`byte string extends beyond input`),{value:new M(new Uint8Array(e.buffer,e.byteOffset+a,i).slice(),{encodingWidth:s}),nextOffset:a+i}}case 3:{if(o===31){let{chunks:i,nextOffset:a}=Yn(e,t,n,r,`text string`,e=>e instanceof B);return{value:new P(i),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i);a+i>e.byteLength&&q(`text string extends beyond input`);let c=new Uint8Array(e.buffer,e.byteOffset+a,i),l,u,d=i<64?Kn(c,i):void 0;if(d!==void 0)l=d;else try{l=zn.decode(c)}catch{u=Vn(`invalid UTF-8 sequence in text string`,a,n),l=Bn.decode(c)}let f=new B(l,{encodingWidth:s});return u&&J(f,u),{value:f,nextOffset:a+i}}case 4:{if(o===31){let i=[],a=t;for(;;){if(a>=e.byteLength&&q(`unexpected end of indefinite array`),e.getUint8(a)===255){a++;break}let t=X(e,a,n,r);i.push(t.value),a=t.nextOffset}return{value:new F(i,{indefiniteLength:!0}),nextOffset:a}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i),c=[],l=a;for(let t=0;t<i;t++){let t=X(e,l,n,r);c.push(t.value),l=t.nextOffset}return{value:new F(c,{encodingWidth:s}),nextOffset:l}}case 5:{if(o===31){let i=[],a=new Set,o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite map`),e.getUint8(s)===255){s++;break}let t=X(e,s,n,r);Xn(t.value,a,o,n),s=t.nextOffset;let c=X(e,s,n,r);s=c.nextOffset,i.push([t.value,c.value])}let c=new I(i,{indefiniteLength:!0});for(let e of o)J(c,e);return{value:c,nextOffset:s}}let{value:i,nextOffset:a}=Jn(e,t,o),s=Rn(o,i),c=[],l=new Set,u=[],d=a;for(let t=0;t<i;t++){let t=X(e,d,n,r);Xn(t.value,l,u,n),d=t.nextOffset;let i=X(e,d,n,r);d=i.nextOffset,c.push([t.value,i.value])}let f=new I(c,{encodingWidth:s});for(let e of u)J(f,e);return{value:f,nextOffset:d}}case 6:{o===31&&q(`tags cannot use indefinite-length encoding`);let{value:i,nextOffset:a}=qn(e,t,o),s=Ln(o,i),c=X(e,a,n,r);for(let e of r){let t=e.parseTag(i,c.value,n);if(t!==void 0)return t instanceof j&&s!==void 0&&(t.encodingWidth=s),{value:t,nextOffset:c.nextOffset}}return{value:new j(i,c.value,{encodingWidth:s}),nextOffset:c.nextOffset}}case 7:if(o<=19)return{value:new L(o),nextOffset:t};if(o===20)return{value:new L(20),nextOffset:t};if(o===21)return{value:new L(21),nextOffset:t};if(o===22)return{value:new L(22),nextOffset:t};if(o===23)return{value:new L(23),nextOffset:t};if(o===24){t+1>e.byteLength&&q(`unexpected end of input`);let r=e.getUint8(t);if(r<32){let e=Vn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`,t-1,n),i=new L(r);return J(i,e),{value:i,nextOffset:t+1}}return{value:new L(r),nextOffset:t+1}}if(o===25){t+2>e.byteLength&&q(`unexpected end of input`);let n=C(e.getUint16(t,!1));return{value:new A(n,{precision:`half`,rawBits:Number.isNaN(n)?Zn(e,t,2):void 0}),nextOffset:t+2}}if(o===26){t+4>e.byteLength&&q(`unexpected end of input`);let n=e.getFloat32(t,!1);return{value:new A(n,{precision:`single`,rawBits:Number.isNaN(n)?Zn(e,t,4):void 0}),nextOffset:t+4}}if(o===27){t+8>e.byteLength&&q(`unexpected end of input`);let n=e.getFloat64(t,!1);return{value:new A(n,{precision:`double`,rawBits:Number.isNaN(n)?Zn(e,t,8):void 0}),nextOffset:t+8}}return o<31&&q(`reserved additional info value in major type 7: ${o}`),q(`unexpected break code outside indefinite-length item`)}return q(`unknown major type: ${a}`)}function $n(e){if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`expected ArrayBufferView or ArrayBufferLike`)}function er(e,t){let n=$n(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=t?.offset??0;if(!Number.isInteger(i)||i<0||i>r.byteLength)throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);let a=Gn(t?.builtinExtensions),o=t?.extensions?.length?[...t.extensions.filter(e=>e.parseTag!==void 0),...a]:a,{value:s,nextOffset:c}=X(r,i,t,o);if(!t?.allowTrailing&&c!==r.byteLength){J(s,Vn(`${r.byteLength-c} trailing byte(s) after end of CBOR item`,c,t));let e={strict:!1,silent:!0},n=c;for(;n<r.byteLength;)({nextOffset:n}=X(r,n,e,o))}return s}var tr=24n,nr={tagNumbers:[tr],parseTag(e,t,n){if(e!==24n||!(t instanceof M))return;let r=(t.end??t.value.length)-t.value.length,i=n?{extensions:n.extensions,builtinExtensions:n.builtinExtensions,strict:n.strict,onWarning:n.onWarning?e=>n.onWarning({...e,offset:e.offset+r}):void 0,silent:n.silent}:void 0;try{return new j(tr,new ze([er(t.value,i)],{encodingWidth:t.encodingWidth}))}catch(e){if(i?.strict!==!1)throw e;let t=`tag 24 content is not valid CBOR: ${e instanceof Error?e.message:String(e)}`,a={message:t,offset:r};n?.onWarning?n.onWarning(a):n?.silent||console.warn(`CBOR strict violation at offset ${a.offset}: ${t}`);return}}};function rr(e){return e instanceof R&&!(e.content instanceof F)}function ir(e){let t=!1,n=!1,r=!1,i;for(let a of e){let e;if(rr(a))e=!0,r=!0;else if(a instanceof B)e=!1,t=!0;else if(a instanceof M)e=!1,n=!0;else return!1;if(e===i)return!1;i=e}return r&&!(t&&n)}var ar={tagNumbers:[Ue],parseTag(e,t){if(e===888n){if(t instanceof L&&t.value===22)return new R;if(t instanceof F&&ir(t.items))return new R(t.items)}}},or=new TextEncoder,sr=new TextDecoder(`utf-8`,{fatal:!0}),cr=new TextDecoder(`utf-8`,{fatal:!1}),lr=Symbol(`ellipsis`);function ur(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function dr(e,t,n){if(t instanceof He){dr(e,t.inner,n);return}if(t instanceof R){if(t.content instanceof F)for(let r of t.content.items)dr(e,r,n);else n.push(lr);return}if(t instanceof B){n.push(or.encode(t.value));return}if(t instanceof M){n.push(t.value);return}if(t instanceof P){n.push(or.encode(t.chunks.map(e=>e.value).join(``)));return}if(t instanceof N){n.push(ur(t.chunks.map(e=>e.value)));return}throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`)}function fr(e,t){try{return sr.decode(e)}catch{let n=`t1 concatenation result is not valid UTF-8`;if(t)t(n);else throw SyntaxError(n);return cr.decode(e)}}function pr(e,t,n){let r=[];for(let n of t)dr(e,n,r);let i=e===`t1`,a=[],o=!1,s=[],c=()=>{if(s.length===0)return;let e=ur(s);s.length=0,e.length!==0&&a.push(i?new B(fr(e,n)):new M(e))};for(let e of r)e===lr?(c(),a[a.length-1]instanceof R||(a.push(new R),o=!0)):s.push(e);if(!o){let e=ur(s);return i?new B(fr(e,n)):new M(e)}return c(),a.length===1?new R:new R(a)}function mr(e){return{appStringPrefixes:[e],preserveAppSeqSource:!0,parseAppString(t,n,r){return pr(e,[new B(n)],r)},parseAppSequence(t,n,r){return pr(e,n,r)}}}var hr=mr(`t1`),gr=mr(`b1`),_r=new TextEncoder,vr=new TextDecoder(`utf-8`,{fatal:!0}),yr=new TextDecoder(`utf-8`,{fatal:!1});function br(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function xr(e,t,n){let r=e===`ilts`,i=[],a=[];for(let o of t){if(o instanceof He&&(o=o.inner),o instanceof R)throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);let t,s,c;if(o instanceof B)t=o.value,c=o.encodingWidth;else if(o instanceof M)s=o.value,c=o.encodingWidth;else if(o instanceof P)t=o.chunks.map(e=>e.value).join(``);else if(o instanceof N)s=br(o.chunks.map(e=>e.value));else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);if(r){let e;if(t!==void 0)e=t;else try{e=vr.decode(s)}catch{let t=`ilts chunk is not valid UTF-8`;if(n)n(t);else throw SyntaxError(t);e=yr.decode(s)}a.push(new B(e,c===void 0?void 0:{encodingWidth:c}))}else{let e=s??_r.encode(t);i.push(new M(e,c===void 0?void 0:{encodingWidth:c}))}}return r?new P(a):new N(i)}function Sr(e){return{appStringPrefixes:[e],preserveAppSeqSource:!0,parseAppString(t,n,r){return new He(xr(e,[new B(n)],r),`${e}${ge(n)}`)},parseAppSequence(t,n,r){return xr(e,n,r)}}}var Cr=Sr(`ilbs`),wr=Sr(`ilts`);function Tr(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===`
12
12
  `||r===`\r`){n++;continue}if(r===`#`){for(;n<e.length&&e[n]!==`
13
13
  `;)n++;continue}if(r===`/`){let t=e[n+1]??``;if(t===`/`){for(;n<e.length&&e[n]!==`
14
14
  `;)n++;continue}if(t===`*`){for(n+=2;n<e.length&&!(e[n]===`*`&&(e[n+1]??``)===`/`);)n++;if(n>=e.length)throw SyntaxError(`unterminated block comment`);n+=2;continue}for(n++;n<e.length&&e[n]!==`/`;)n++;if(n>=e.length)throw SyntaxError(`unterminated block comment`);n++;continue}t+=r,n++}return t}var Er=class extends A{_bits;constructor(e){super(C(e),{precision:`half`}),this._bits=e&65535}_toCBOR(){return new Uint8Array([249,this._bits>>8&255,this._bits&255])}},Dr=class extends A{_raw;constructor(e){super(new DataView(e.buffer,e.byteOffset).getFloat32(0,!1),{precision:`single`}),this._raw=e.slice()}_toCBOR(){let e=new Uint8Array(5);return e[0]=250,e.set(this._raw,1),e}},Or=class extends A{_raw;constructor(e){super(new DataView(e.buffer,e.byteOffset).getFloat64(0,!1),{precision:`double`}),this._raw=e.slice()}_toCBOR(){let e=new Uint8Array(9);return e[0]=251,e.set(this._raw,1),e}};function kr(e){if(e.length===2)return new Er(e[0]<<8|e[1]);if(e.length===4)return new Dr(e);if(e.length===8)return new Or(e);throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`)}function Ar(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023,i;if(n===31)i=t<<31|2139095040|r<<13;else if(n===0&&r===0)i=t<<31;else if(n===0){let e=r,n=0;for(;!(e&512);)e<<=1,n++;i=t<<31|112-n<<23|(e&511)<<14}else i=t<<31|n+112<<23|r<<13;let a=new Uint8Array(4);return new DataView(a.buffer).setUint32(0,i>>>0,!1),a}function jr(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023,i=new Uint8Array(8),a=new DataView(i.buffer);if(n===31)a.setUint32(0,(t<<31|2146435072|r<<10)>>>0,!1),a.setUint32(4,0,!1);else if(n===0&&r===0)a.setUint32(0,t<<31>>>0,!1),a.setUint32(4,0,!1);else if(n===0){let e=r,n=0;for(;!(e&512);)e<<=1,n++;a.setUint32(0,(t<<31|1008-n<<20|(e&511)<<11)>>>0,!1),a.setUint32(4,0,!1)}else a.setUint32(0,(t<<31|n+1008<<20|r<<10)>>>0,!1),a.setUint32(4,0,!1);return i}function Mr(e){let t=new DataView(e.buffer,e.byteOffset).getUint32(0,!1),n=t>>>31&1,r=t>>>23&255,i=t&8388607,a=new Uint8Array(8),o=new DataView(a.buffer);if(r===255)o.setUint32(0,(n<<31|2146435072|i>>>3)>>>0,!1),o.setUint32(4,(i&7)<<29,!1);else if(r===0&&i===0)o.setUint32(0,n<<31>>>0,!1),o.setUint32(4,0,!1);else{let t=new DataView(e.buffer,e.byteOffset).getFloat32(0,!1);o.setFloat64(0,t,!1)}return a}function Nr(e,t,n){let r=e.length===2?1:e.length===4?2:3;if(r===1){let n=e[0]<<8|e[1];if(t===2)return new Dr(Ar(n));if(t===3)return new Or(jr(n))}if(r===2){if(t===3)return new Or(Mr(e));if(t===1){let t=new DataView(e.buffer,e.byteOffset).getFloat32(0,!1),r=S(t);return!Object.is(C(r),t)&&!isNaN(t)&&n(`float'...' value cannot be exactly represented as float16 (_1)`),new Er(r)}}if(r===3){let r=new DataView(e.buffer,e.byteOffset).getFloat64(0,!1);if(t===1){let e=S(r);return!Object.is(C(e),r)&&!isNaN(r)&&n(`float'...' value cannot be exactly represented as float16 (_1)`),new Er(e)}if(t===2){let e=Math.fround(r);!Object.is(e,r)&&!isNaN(r)&&n(`float'...' value cannot be exactly represented as float32 (_2)`);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!1),new Dr(t)}}return kr(e)}var Pr={appStringPrefixes:[`float`],parseAppString(t,n,r,i){let a=Tr(n);if(!/^[0-9a-fA-F]*$/.test(a))throw SyntaxError(`float'...' contains non-hex characters`);if(a.length%2!=0)throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);let o=e.a(a),s=i?.encodingWidth;if(s===void 0)return kr(o);if(s!==1&&s!==2&&s!==3){let e=`float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;if(r)return r(e),kr(o);throw SyntaxError(e)}return s===(o.length===2?1:o.length===4?2:3)?kr(o):Nr(o,s,r??(e=>{throw SyntaxError(e)}))},parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`float<<...>> requires exactly one byte-string item`);if(t.length>1){let e=`float<<...>> expects 1 item; got ${t.length} — using first`;if(n)n(e);else throw SyntaxError(e)}if(!(t[0]instanceof M))throw SyntaxError(`float<<...>> item must be a byte string`);return kr(t[0].value)}},Fr=[In,nr,ar],Ir=[Ht,sn,Nn,hr,gr,Cr,wr,Pr],Lr;function Z(e){return e===void 0?Lr??=[...Fr,...Ir]:e===!1?Fr:[...Fr,...e]}var Rr;function zr(e){if(e===void 0){if(Rr)return Rr;let e=Z(void 0);return Rr={fromJS:e.filter(e=>e.fromJS!==void 0),parseTag:e.filter(e=>e.parseTag!==void 0)}}let t=Z(e);return{fromJS:t.filter(e=>e.fromJS!==void 0),parseTag:t.filter(e=>e.parseTag!==void 0)}}function Br(e){let t=e?.extensions,n=zr(e?.builtinExtensions);return t?.length?{fromJS:[...t.filter(e=>e.fromJS!==void 0),...n.fromJS],parseTag:[...t.filter(e=>e.parseTag!==void 0),...n.parseTag]}:n}function Vr(e,t){if(t?.replacer){let{replacer:n,...r}=t,i=Ur(e,n,r.extensions,r.undefinedOmits,r.builtinExtensions);return i===u?L.UNDEFINED:Vr(i,Object.keys(r).length>0?r:void 0)}return Q(e,t,!0,Br(t))}function Q(e,t,n,r){for(let n of r.fromJS){let r=n.fromJS(e,t??{});if(r!==void 0)return r}if(n&&typeof e==`object`&&e&&l.symbol in e){let n=e[l.symbol],i=Q(e,t,!1,r);for(let e of r.parseTag){let t=e.parseTag(n,i);if(t!==void 0)return t}return new j(n,i)}if(e instanceof l.Null)return L.NULL;if(e instanceof l.Undefined)return L.UNDEFINED;if(e instanceof d)return new L(e.value);if(e===null)return L.NULL;if(e===void 0)return L.UNDEFINED;if(e===!0)return L.TRUE;if(e===!1)return L.FALSE;if(typeof e==`bigint`)return e>18446744073709551615n?new Xe(e):e<-18446744073709551616n?new Ze(e):e>=0n?new O(e):new k(e);if(typeof e==`number`)return(t?.encodeIntegerAs??`int`)===`int`&&Number.isInteger(e)&&!Object.is(e,-0)?e>=0?new O(BigInt(e)):new k(BigInt(e)):new A(e);if(typeof e==`string`)return new B(e);if(e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`)return Q(e.valueOf(),t,!1,r);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new M(new Uint8Array(e));if(ArrayBuffer.isView(e))return e instanceof Uint8Array&&t?.uint8ArrayAs===`array`?new F(Array.from(e,e=>new O(BigInt(e)))):new M(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));if(e instanceof $)return new I([...e].map(([e,n])=>[Q(e,t,!0,r),Q(n,t,!0,r)]));if(Array.isArray(e))return new F(e.map(e=>Q(e,t,!0,r)));if(typeof e==`object`){let n=[];for(let[i,a]of Object.entries(e))n.push([new B(i),Q(a,t,!0,r)]);return new I(n)}throw TypeError(`fromJS: unsupported value type: ${typeof e}`)}function Hr(e){return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`||e instanceof l.Null||e instanceof l.Undefined||e instanceof d}function Ur(e,t,n,r,i){let a=[...n??[],...Z(i)].filter(e=>e.isJSType!==void 0);function o(e){return e===u||r===!0&&e===void 0}if(Array.isArray(t)){let n=t.map(String);function s(e){if(typeof e!=`object`||!e)return e;if(e instanceof $)return $.from(e,([e,t])=>[e,s(t)]);if(Array.isArray(e))return e.map(s);if(l.symbol in e||Hr(e)||a.some(t=>t.isJSType(e)))return e;let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){let t=e.toJSON;if(typeof t==`function`)return s(t.call(e))}let r={};for(let t of n)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=s(e[t]));return r}return s(e)}let c=t;function d(e,t,n){if(typeof e==`object`&&e&&!(e instanceof $)){let n=Object.getPrototypeOf(e);if(n===Object.prototype||n===null){let n=e.toJSON;typeof n==`function`&&(e=n.call(e,t))}}if(e=c.call(n,t,e),typeof e==`object`&&e){if(l.symbol in e)return e;if(e instanceof $){let t=new $;for(let[n,r]of e){let i=d(r,n,e);o(i)||t.push([n,i])}return t}if(Array.isArray(e))return e.map((t,n)=>{let r=d(t,String(n),e);return o(r)?null:r});if(Hr(e)||a.some(t=>t.isJSType(e)))return e;let t={};for(let n of Object.keys(e)){let r=d(e[n],n,e);o(r)||(t[n]=r)}return t}return e}return d(e,``,{"":e})}var $=class extends Array{toJSON(){let e={};for(let[t,n]of this){let r=typeof t==`string`?t:Vr(t).toCDN();r===`__proto__`?Object.defineProperty(e,r,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[r]=n}return e}};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return er}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return sn}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Xe}});
15
- //# sourceMappingURL=mapEntries-CV9kf2OS.cjs.map
15
+ //# sourceMappingURL=mapEntries-DDJxbotH.cjs.map