{"version":3,"file":"filepath-to-prop-path.mjs","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport fp from 'lodash/fp';\n\n/**\n * Returns a path (as an array) from a file path\n */\nexport const filePathToPropPath = (\n  entryPath: string,\n  useFileNameAsKey: boolean = true\n): string[] => {\n  const transform = fp.pipe(\n    // Remove the relative path prefixes: './' for posix (and some win32) and \".\\\" for win32\n    removeRelativePrefix,\n    // Remove the path metadata and extensions\n    fp.replace(/(\\.settings|\\.json|\\.js)/g, ''),\n    // Transform to lowercase\n    // Note: We're using fp.toLower instead of fp.lowercase as the latest removes special characters such as \"/\"\n    fp.toLower,\n    // Split the cleaned path by matching every possible separator (either \"/\" or \"\\\" depending on the OS)\n    fp.split(new RegExp(`[\\\\${path.win32.sep}|${path.posix.sep}]`, 'g')),\n    // Make sure to remove leading '.' from the different path parts\n    fp.map(fp.trimCharsStart('.')),\n    // join + split in case some '.' characters are still present in different parts of the path\n    fp.join('.'),\n    fp.split('.'),\n    // Remove the last portion of the path array if the file name shouldn't be used as a key\n    useFileNameAsKey ? fp.identity : fp.slice(0, -1)\n  );\n\n  return transform(entryPath) as string[];\n};\n\nconst removeRelativePrefix = (filePath: string) => {\n  return filePath.startsWith(`.${path.win32.sep}`) || filePath.startsWith(`.${path.posix.sep}`)\n    ? filePath.slice(2)\n    : filePath;\n};\n"],"names":["filePathToPropPath","entryPath","useFileNameAsKey","transform","fp","pipe","removeRelativePrefix","replace","toLower","split","RegExp","path","win32","sep","posix","map","trimCharsStart","join","identity","slice","filePath","startsWith"],"mappings":";;;AAGA;;AAEC,IACM,MAAMA,kBAAAA,GAAqB,CAChCC,SAAAA,EACAC,mBAA4B,IAAI,GAAA;AAEhC,IAAA,MAAMC,SAAAA,GAAYC,EAAAA,CAAGC,IAAI;AAEvBC,IAAAA,oBAAAA;AAEAF,IAAAA,EAAAA,CAAGG,OAAO,CAAC,2BAAA,EAA6B,EAAA,CAAA;;IAGxCH,EAAAA,CAAGI,OAAO;IAEVJ,EAAAA,CAAGK,KAAK,CAAC,IAAIC,MAAAA,CAAO,CAAC,GAAG,EAAEC,IAAAA,CAAKC,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEF,IAAAA,CAAKG,KAAK,CAACD,GAAG,CAAC,CAAC,CAAC,EAAE,GAAA,CAAA,CAAA;AAE/DT,IAAAA,EAAAA,CAAGW,GAAG,CAACX,EAAAA,CAAGY,cAAc,CAAC;AAEzBZ,IAAAA,EAAAA,CAAGa,IAAI,CAAC,GAAA,CAAA,EACRb,GAAGK,KAAK,CAAC;AAETP,IAAAA,gBAAAA,GAAmBE,GAAGc,QAAQ,GAAGd,GAAGe,KAAK,CAAC,GAAG,EAAC,CAAA,CAAA;AAGhD,IAAA,OAAOhB,SAAAA,CAAUF,SAAAA,CAAAA;AACnB;AAEA,MAAMK,uBAAuB,CAACc,QAAAA,GAAAA;IAC5B,OAAOA,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAAA,CAAKC,KAAK,CAACC,GAAG,CAAA,CAAE,CAAA,IAAKO,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAAA,CAAKG,KAAK,CAACD,GAAG,CAAA,CAAE,CAAA,GACxFO,QAAAA,CAASD,KAAK,CAAC,CAAA,CAAA,GACfC,QAAAA;AACN,CAAA;;;;"}