{"version":3,"file":"sdf-parser.umd.js","sources":["../node_modules/ensure-string/lib/index.js","../lib/getEntriesBoundaries.js","../lib/util/getMolecule.js","../lib/parse.js","../node_modules/dynamic-typing/lib/parseString.js","../lib/MolfileStream.js","../lib/iterator.js"],"sourcesContent":["/**\n * Ensure that the data is string. If it is an ArrayBuffer it will be converted to string using TextDecoder.\n * @param blob\n * @param options\n * @returns\n */\nexport function ensureString(blob, options = {}) {\n    if (typeof blob === 'string') {\n        return blob;\n    }\n    if (ArrayBuffer.isView(blob) || blob instanceof ArrayBuffer) {\n        if (options.encoding) {\n            return new TextDecoder(options.encoding).decode(blob);\n        }\n        else {\n            return decodeText(blob);\n        }\n    }\n    throw new TypeError(`blob must be a string, ArrayBuffer or ArrayBufferView`);\n}\nfunction decodeText(blob) {\n    const uint8 = ArrayBuffer.isView(blob)\n        ? new Uint8Array(blob.buffer, blob.byteOffset, blob.byteLength)\n        : new Uint8Array(blob);\n    if (uint8.length >= 2) {\n        if (uint8[0] === 0xfe && uint8[1] === 0xff) {\n            return new TextDecoder('utf-16be').decode(uint8);\n        }\n        if (uint8[0] === 0xff && uint8[1] === 0xfe) {\n            return new TextDecoder('utf-16le').decode(uint8);\n        }\n    }\n    try {\n        return new TextDecoder('utf-8', { fatal: true }).decode(uint8);\n    }\n    catch {\n        return new TextDecoder('latin1').decode(uint8);\n    }\n}\n//# sourceMappingURL=index.js.map","/**\n * Get the [start, end] boundaries of each SDF entry in a string.\n *\n * Uses `indexOf` for fast splitting without regex overhead.\n * @param string - The full SDF string.\n * @param substring - The delimiter to search for (e.g. `'\\n$$$$'`).\n * @param eol - The end-of-line character used to skip past the delimiter line.\n * @returns An array of `[start, end]` index pairs, one per SDF entry.\n */\nexport function getEntriesBoundaries(string, substring, eol) {\n    const res = [];\n    let previous = 0;\n    let next = 0;\n    while (next !== -1) {\n        next = string.indexOf(substring, previous);\n        if (next !== -1) {\n            res.push([previous, next]);\n            const nextMatch = string.indexOf(eol, next + substring.length);\n            if (nextMatch === -1) {\n                next = -1;\n            }\n            else {\n                previous = nextMatch + eol.length;\n                next = previous;\n            }\n        }\n        else {\n            res.push([previous, string.length]);\n        }\n    }\n    return res;\n}\n//# sourceMappingURL=getEntriesBoundaries.js.map","/**\n * Parse a single SDF entry string into a molecule object.\n * @param sdfPart - A single SDF record (everything before the `$$$$` line).\n * @param labels - Shared label tracking object, mutated in place.\n * @param currentLabels - Array to collect label names found in this entry.\n * @param options - Resolved parse options.\n * @returns The molecule object, or `undefined` if the entry is too short.\n */\nexport function getMolecule(sdfPart, labels, currentLabels, options) {\n    const { eol, dynamicTyping, include, exclude, modifiers, forEach } = options;\n    const parts = sdfPart.split(`${eol}>`);\n    if (parts.length === 0 || parts[0].length <= 5)\n        return undefined;\n    const molecule = { molfile: parts[0] + eol };\n    for (let j = 1; j < parts.length; j++) {\n        const lines = parts[j].split(eol);\n        const from = lines[0].indexOf('<');\n        const to = lines[0].indexOf('>');\n        const label = lines[0].slice(from + 1, to);\n        currentLabels.push(label);\n        if (!labels[label]) {\n            labels[label] = {\n                counter: 0,\n                isNumeric: dynamicTyping,\n                keep: false,\n            };\n            if (!exclude?.includes(label) && (!include || include.includes(label))) {\n                labels[label].keep = true;\n                if (modifiers[label])\n                    labels[label].modifier = modifiers[label];\n                if (forEach[label])\n                    labels[label].forEach = forEach[label];\n            }\n        }\n        if (labels[label].keep) {\n            for (let k = 1; k < lines.length - 1; k++) {\n                if (molecule[label]) {\n                    molecule[label] = `${molecule[label]}${eol}${lines[k]}`;\n                }\n                else {\n                    molecule[label] = lines[k];\n                }\n            }\n            if (labels[label].modifier) {\n                const modifiedValue = labels[label].modifier(molecule[label]);\n                if (modifiedValue === undefined || modifiedValue === null) {\n                    // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n                    delete molecule[label];\n                }\n                else {\n                    molecule[label] = modifiedValue;\n                }\n            }\n            if (labels[label].isNumeric &&\n                (!Number.isFinite(+molecule[label]) ||\n                    molecule[label].match(/^0[0-9]/))) {\n                labels[label].isNumeric = false;\n            }\n        }\n    }\n    return molecule;\n}\n//# sourceMappingURL=getMolecule.js.map","import { ensureString } from 'ensure-string';\nimport { getEntriesBoundaries } from \"./getEntriesBoundaries.js\";\nimport { getMolecule } from \"./util/getMolecule.js\";\n/**\n * Synchronously parse an SDF file into an array of molecule objects.\n * @param sdf - The SDF content as a string, `ArrayBuffer`, or `ArrayBufferView`.\n * @param options - Parsing options.\n * @returns A {@link ParseResult} containing molecules and statistics.\n * @example\n * ```ts\n * import { readFileSync } from 'node:fs';\n * import { parse } from 'sdf-parser';\n *\n * const sdf = readFileSync('compounds.sdf', 'utf8');\n * const { molecules, statistics } = parse(sdf);\n * ```\n */\nexport function parse(sdf, options = {}) {\n    options = { ...options };\n    if (options.modifiers === undefined)\n        options.modifiers = {};\n    if (options.forEach === undefined)\n        options.forEach = {};\n    if (options.dynamicTyping === undefined)\n        options.dynamicTyping = true;\n    // ensureString converts ArrayBuffer/ArrayBufferView to string\n    const sdfString = ensureString(sdf);\n    if (typeof sdfString !== 'string') {\n        throw new TypeError('Parameter \"sdf\" must be a string');\n    }\n    if (options.eol === undefined) {\n        options.eol = '\\n';\n        if (options.mixedEOL) {\n            // Normalize all line endings to \\n\n            // We work on a local variable so no issue here\n        }\n        else {\n            // Note: new Set(string) creates a Set of individual characters.\n            // '\\r\\n' is two characters so header.has('\\r\\n') would always be false.\n            // This preserves the original detection behaviour.\n            const header = new Set(sdfString.slice(0, 1000));\n            if (header.has('\\r\\n')) {\n                options.eol = '\\r\\n';\n            }\n            else if (header.has('\\r')) {\n                options.eol = '\\r';\n            }\n        }\n    }\n    let workingSdf = sdfString;\n    if (options.mixedEOL) {\n        workingSdf = workingSdf.replaceAll('\\r\\n', '\\n');\n        workingSdf = workingSdf.replaceAll('\\r', '\\n');\n    }\n    const eol = options.eol;\n    const modifiers = options.modifiers;\n    const forEachMap = options.forEach;\n    const dynamicTyping = options.dynamicTyping;\n    const entriesBoundaries = getEntriesBoundaries(workingSdf, `${eol}$$$$`, eol);\n    const molecules = [];\n    const labels = {};\n    const start = Date.now();\n    for (const boundary of entriesBoundaries) {\n        const sdfPart = workingSdf.slice(...boundary);\n        if (sdfPart.length < 40)\n            continue;\n        const currentLabels = [];\n        const molecule = getMolecule(sdfPart, labels, currentLabels, {\n            eol,\n            dynamicTyping,\n            modifiers,\n            forEach: forEachMap,\n            include: options.include,\n            exclude: options.exclude,\n        });\n        if (!molecule)\n            continue;\n        if (!options.filter || options.filter(molecule)) {\n            molecules.push(molecule);\n            for (const label of currentLabels) {\n                labels[label].counter++;\n            }\n        }\n    }\n    // Convert all numeric fields and compute min/max\n    for (const label in labels) {\n        const currentLabel = labels[label];\n        if (currentLabel.isNumeric) {\n            currentLabel.minValue = Infinity;\n            currentLabel.maxValue = -Infinity;\n            for (const molecule of molecules) {\n                if (molecule[label]) {\n                    const value = Number.parseFloat(molecule[label]);\n                    molecule[label] = value;\n                    if (value > (currentLabel.maxValue ?? -Infinity)) {\n                        currentLabel.maxValue = value;\n                    }\n                    if (value < (currentLabel.minValue ?? Infinity)) {\n                        currentLabel.minValue = value;\n                    }\n                }\n            }\n        }\n    }\n    for (const key in labels) {\n        labels[key].always = labels[key].counter === molecules.length;\n    }\n    const statistics = [];\n    for (const key in labels) {\n        const info = labels[key];\n        statistics.push({\n            label: key,\n            counter: info.counter,\n            isNumeric: info.isNumeric,\n            keep: info.keep,\n            minValue: info.minValue,\n            maxValue: info.maxValue,\n            always: info.always ?? false,\n        });\n    }\n    return {\n        time: Date.now() - start,\n        molecules,\n        labels: Object.keys(labels),\n        statistics,\n    };\n}\n//# sourceMappingURL=parse.js.map","export function parseString(value) {\n    if (value.length === 4 || value.length === 5) {\n        const lowercase = value.toLowerCase();\n        if (lowercase === 'true')\n            return true;\n        if (lowercase === 'false')\n            return false;\n    }\n    const number = Number(value);\n    if (number === 0 && !value.includes('0')) {\n        return value;\n    }\n    if (!Number.isNaN(number))\n        return number;\n    return value;\n}\n//# sourceMappingURL=parseString.js.map","/**\n * A Web Streams API `TransformStream` that splits an incoming text stream on\n * the `$$$$` SDF record delimiter and emits individual molfile strings.\n *\n * Entries shorter than 40 characters are discarded.\n * @example\n * ```ts\n * const stream = readStream.pipeThrough(new MolfileStream());\n * for await (const molfile of stream) {\n *   console.log(molfile);\n * }\n * ```\n */\nexport class MolfileStream extends TransformStream {\n    #buffer = [];\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    constructor(_options) {\n        super({\n            transform: (chunk, controller) => {\n                this.#buffer.push(chunk);\n                const combined = this.#buffer.join('');\n                this.#buffer.length = 0;\n                let begin = 0;\n                let index = 0;\n                while ((index = combined.indexOf('$$$$', index)) !== -1) {\n                    const endOfDelimiter = combined.indexOf('\\n', index);\n                    if (endOfDelimiter === -1) {\n                        index = begin;\n                        break;\n                    }\n                    const eolLength = combined[endOfDelimiter - 1] === '\\r' ? 2 : 1;\n                    // Remove the last eol before enqueuing\n                    if (index - eolLength - begin > 40) {\n                        controller.enqueue(combined.slice(begin, index - eolLength));\n                    }\n                    index = endOfDelimiter + eolLength;\n                    begin = index;\n                }\n                if (begin < combined.length) {\n                    this.#buffer.push(combined.slice(begin));\n                }\n            },\n            flush: (controller) => {\n                const remaining = this.#buffer.join('');\n                if (remaining && remaining.length > 40) {\n                    controller.enqueue(remaining);\n                }\n            },\n        });\n    }\n}\n//# sourceMappingURL=MolfileStream.js.map","import { parseString } from 'dynamic-typing';\nimport { MolfileStream } from \"./MolfileStream.js\";\n/**\n * Asynchronously iterate over molecules from a text-decoded SDF stream.\n * @param readStream - A `ReadableStream<string>` supplying SDF text content.\n * @param options - Iterator options.\n * @yields {IteratorMolecule} Individual molecule objects.\n * @example\n * ```ts\n * import { openAsBlob } from 'node:fs';\n * import { iterator } from 'sdf-parser';\n *\n * const blob = await openAsBlob('compounds.sdf');\n * const textDecoder = new TextDecoderStream();\n * for await (const molecule of iterator(blob.stream().pipeThrough(textDecoder))) {\n *   console.log(molecule.molfile);\n * }\n * ```\n */\nexport async function* iterator(readStream, options = {}) {\n    const { eol = '\\n', dynamicTyping = true } = options;\n    const moleculeStream = readStream.pipeThrough(new MolfileStream({ eol }));\n    for await (const entry of moleculeStream) {\n        const molecule = parseMolecule(entry, { eol, dynamicTyping });\n        if (!options.filter || options.filter(molecule)) {\n            yield molecule;\n        }\n    }\n}\nfunction parseMolecule(sdfPart, options) {\n    const { eol, dynamicTyping } = options;\n    const parts = sdfPart.split(`${eol}>`);\n    const molecule = {\n        molfile: parts.length > 0 && parts[0].length > 5 ? parts[0] + eol : '',\n    };\n    for (let j = 1; j < parts.length; j++) {\n        const lines = parts[j].split(eol);\n        const from = lines[0].indexOf('<');\n        const to = lines[0].indexOf('>');\n        const label = lines[0].slice(from + 1, to);\n        for (let k = 1; k < lines.length - 1; k++) {\n            if (molecule[label]) {\n                molecule[label] = `${molecule[label]}${eol}${lines[k]}`;\n            }\n            else {\n                molecule[label] = lines[k];\n            }\n        }\n        if (dynamicTyping) {\n            molecule[label] = parseString(molecule[label]);\n        }\n    }\n    return molecule;\n}\n//# sourceMappingURL=iterator.js.map"],"names":["ensureString","blob","options","ArrayBuffer","isView","encoding","TextDecoder","decode","decodeText","TypeError","uint8","Uint8Array","buffer","byteOffset","byteLength","length","fatal","getEntriesBoundaries","string","substring","eol","res","previous","next","indexOf","push","nextMatch","getMolecule","sdfPart","labels","currentLabels","dynamicTyping","include","exclude","modifiers","forEach","parts","split","undefined","molecule","molfile","j","lines","from","to","label","slice","counter","isNumeric","keep","includes","modifier","k","modifiedValue","Number","isFinite","match","parse","sdf","sdfString","mixedEOL","header","Set","has","workingSdf","replaceAll","forEachMap","entriesBoundaries","molecules","start","Date","now","boundary","filter","currentLabel","minValue","Infinity","maxValue","value","parseFloat","key","always","statistics","info","time","Object","keys","parseString","lowercase","toLowerCase","number","isNaN","MolfileStream","TransformStream","constructor","_options","transform","chunk","controller","combined","join","begin","index","endOfDelimiter","eolLength","enqueue","flush","remaining","iterator","readStream","moleculeStream","pipeThrough","entry","parseMolecule"],"m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