{"version":3,"file":"quilt-file.mjs","names":["#quilt","#sliverIndex","#identifier","#tags"],"sources":["../../../src/files/readers/quilt-file.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { FileReader } from '../file.js';\nimport type { QuiltReader } from './quilt.js';\n\nexport interface QuiltBlobHeader {\n\tidentifier: string;\n\ttags: Record<string, string> | null;\n\tblobSize: number;\n\tcontentOffset: number;\n\tcolumnSize: number;\n}\n\nexport class QuiltFileReader implements FileReader {\n\t#quilt: QuiltReader;\n\t#sliverIndex: number;\n\t#identifier: string | null;\n\t#tags?: Record<string, string>;\n\n\tconstructor({\n\t\tquilt,\n\t\tsliverIndex,\n\t\tidentifier,\n\t\ttags,\n\t}: {\n\t\tquilt: QuiltReader;\n\t\tsliverIndex: number;\n\t\tidentifier?: string;\n\t\ttags?: Record<string, string>;\n\t}) {\n\t\tthis.#quilt = quilt;\n\t\tthis.#sliverIndex = sliverIndex;\n\t\tthis.#identifier = identifier ?? null;\n\t\tthis.#tags = tags;\n\t}\n\n\tasync getBytes(): Promise<Uint8Array> {\n\t\tconst { blobContents, identifier, tags } = await this.#quilt.readBlob(this.#sliverIndex);\n\t\tthis.#identifier = identifier;\n\t\tthis.#tags = tags ?? {};\n\t\treturn blobContents;\n\t}\n\n\tasync getIdentifier() {\n\t\tif (this.#identifier !== null) {\n\t\t\treturn this.#identifier;\n\t\t}\n\n\t\tconst header = await this.#quilt.getBlobHeader(this.#sliverIndex);\n\n\t\tthis.#identifier = header.identifier;\n\t\treturn this.#identifier;\n\t}\n\n\tasync getTags() {\n\t\tif (this.#tags !== undefined) {\n\t\t\treturn this.#tags;\n\t\t}\n\n\t\tconst header = await this.#quilt.getBlobHeader(this.#sliverIndex);\n\t\tthis.#tags = header.tags ?? {};\n\t\treturn this.#tags;\n\t}\n}\n"],"mappings":";AAcA,IAAa,kBAAb,MAAmD;CAClD;CACA;CACA;CACA;CAEA,YAAY,EACX,OACA,aACA,YACA,QAME;AACF,QAAKA,QAAS;AACd,QAAKC,cAAe;AACpB,QAAKC,aAAc,cAAc;AACjC,QAAKC,OAAQ;;CAGd,MAAM,WAAgC;EACrC,MAAM,EAAE,cAAc,YAAY,SAAS,MAAM,MAAKH,MAAO,SAAS,MAAKC,YAAa;AACxF,QAAKC,aAAc;AACnB,QAAKC,OAAQ,QAAQ,EAAE;AACvB,SAAO;;CAGR,MAAM,gBAAgB;AACrB,MAAI,MAAKD,eAAgB,KACxB,QAAO,MAAKA;AAKb,QAAKA,cAFU,MAAM,MAAKF,MAAO,cAAc,MAAKC,YAAa,EAEvC;AAC1B,SAAO,MAAKC;;CAGb,MAAM,UAAU;AACf,MAAI,MAAKC,SAAU,OAClB,QAAO,MAAKA;AAIb,QAAKA,QADU,MAAM,MAAKH,MAAO,cAAc,MAAKC,YAAa,EAC7C,QAAQ,EAAE;AAC9B,SAAO,MAAKE"}