{"version":3,"sources":["jsdelivr-header.js","/npm/second-brain-parser@0.0.27/dist/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,UAAa,oCACf,YAAa,kBACX,YAAa,UAAW,qBAAsB,iCAAqC,2BACnF,YAAa,WAAY,kBAAqB,YAC9C,YAAe,cACf,cAAiB,oCAC1B,MAAM,mBAAsB,IACxB,MAAM,EAAU,QAAQ,SAAS,GACjC,OAAO,MAAM,EAAQ,EAEnB,oBAAsB,CAAC,EAAU,KAEnC,IADoB,WAAW,GAG3B,OADA,QAAQ,KAAK,GAAG,oBACT,KAEX,MAAM,EAAa,mBAAmB,IAC/B,EAAM,GAAkB,YAAY,EAAY,GAEvD,OADA,cAAc,EAAU,UAAU,IAC3B,CAAI,EAET,iBAAmB,CAAC,EAAG,EAAQ,KACjC,QAAQ,IAAI,IAAI,OAAO,GAAQ,GAC1B,EAAE,UAGP,EAAE,SAAS,SAAS,GAAM,iBAAiB,EAAG,EAAQ,IAAG,EAEvD,oBAAuB,GACX,YAAY,EAAK,CAAE,eAAe,IAC5B,QAAO,CAAC,EAAO,KAC/B,MAAM,EAAQ,EAAO,cACf,EAAW,QAAQ,EAAK,EAAO,MAC/B,EAAc,CAChB,qBAAqB,GACrB,6BAA6B,IAEjC,IAAK,UAAU,GACX,OAAO,EAEX,GAAI,EACA,MAAO,IAAI,KAAU,oBAAoB,IAE7C,MAAM,EAAgB,oBAAoB,EAAU,GACpD,OAAI,EACO,IAAI,EAAO,GAEf,CAAK,GACb,IAGD,uBAA0B,GACd,oBAAoB,GACrB,QAAQ,GAAM,EAAE,YAExB,oBAAqB,oBAAqB,UAAW,uBAAwB,qBAAsB,8BAC5G,MAAM,EAAI,oBAAoB,qFAAsF,CAChH,qBAAqB,gEACrB,6BAA6B","file":"/npm/second-brain-parser@0.0.27/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/second-brain-parser@0.0.27/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { parse } from \"uniorg-parse/lib/parser.js\";\nimport toVFile from \"to-vfile\";\nimport { collectNote, isOrgFile, createLinkMiddleware, createPreviewImageMiddleware, } from \"./parser/index.js\";\nimport { readdirSync, existsSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { stringify } from \"uniorg-stringify/lib/stringify.js\";\nconst readOrgFileContent = (filePath) => {\n    const orgFile = toVFile.readSync(filePath);\n    return parse(orgFile);\n};\nconst collectNoteFromFile = (filePath, middlewareChains) => {\n    const isFileExist = existsSync(filePath);\n    if (!isFileExist) {\n        console.warn(`${filePath} does not exist`);\n        return null;\n    }\n    const orgContent = readOrgFileContent(filePath);\n    const [note, updatedOrgData] = collectNote(orgContent, middlewareChains);\n    writeFileSync(filePath, stringify(updatedOrgData));\n    return note;\n};\nconst debugPrettyPrint = (o, level = 0) => {\n    console.log(\" \".repeat(level), o);\n    if (!o.children) {\n        return;\n    }\n    o.children.forEach((c) => debugPrettyPrint(c, level + 2));\n};\nconst collectNotesFromDir = (dir) => {\n    const files = readdirSync(dir, { withFileTypes: true });\n    const notes = files.reduce((notes, dirent) => {\n        const isDir = dirent.isDirectory();\n        const fileName = resolve(dir, dirent.name);\n        const middlewares = [\n            createLinkMiddleware(dir),\n            createPreviewImageMiddleware(dir),\n        ];\n        if (!isOrgFile(fileName)) {\n            return notes;\n        }\n        if (isDir) {\n            return [...notes, ...collectNotesFromDir(fileName)];\n        }\n        const collectedNote = collectNoteFromFile(fileName, middlewares);\n        if (collectedNote) {\n            return [...notes, collectedNote];\n        }\n        return notes;\n    }, []);\n    return notes;\n};\nconst collectOrgNotesFromDir = (dir) => {\n    const notes = collectNotesFromDir(dir);\n    return notes.filter((n) => n.id);\n};\nexport { collectNoteFromFile, collectNotesFromDir, stringify, collectOrgNotesFromDir, createLinkMiddleware, createPreviewImageMiddleware, };\nconst n = collectNoteFromFile(\"/Users/darkawower/Yandex.Disk.localized/Dropbox/org-roam/pet/second-brain-plan.org\", [\n    createLinkMiddleware(\"/Users/darkawower/Yandex.Disk.localized/Dropbox/org-roam/pet\"),\n    createPreviewImageMiddleware(\"/Users/darkawower/Yandex.Disk.localized/Dropbox/org-roam/pet\"),\n]);\n"]}