{
  "version": 3,
  "sources": ["../../src/index.ts"],
  "sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { readFileSync } from 'fs';\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport function readJson(filename: string): any {\n  const filenamePath = resolve(getDataDir(), filename);\n  return JSON.parse(readFileSync(filenamePath, 'utf8'));\n}\n\nlet cachedDataDir: string | undefined = undefined;\n\nexport function getDataDir(): string {\n  if (cachedDataDir) {\n    return cachedDataDir;\n  }\n\n  const currentDir = getCurrentDir();\n\n  // Need to handle the following cases:\n  // v4 and earlier: `index.js` in `dist/`, data in `dist/fhir/`\n  // v5.0.0: data in `index.js` in `dist/cjs/` and `dist/esm/`, data in `/dist/cjs/fhir/` and `/dist/esm/fhir/`\n  // v5.0.1 and after: `index.js` in `dist/cjs/` and `dist/esm/`, data back in `/dist/fhir/`\n  const relativePaths = ['./', '../', './cjs/', './esm/'];\n  for (const relativePath of relativePaths) {\n    const fullPath = resolve(currentDir, relativePath);\n    const fhirPath = resolve(fullPath, 'fhir');\n    if (existsSync(fhirPath)) {\n      cachedDataDir = fullPath;\n      return fullPath;\n    }\n  }\n  throw new Error('No data directory found');\n}\n\nfunction getCurrentDir(): string {\n  if (typeof __dirname !== 'undefined') {\n    return resolve(__dirname);\n  } else if (import.meta.url) {\n    return resolve(dirname(fileURLToPath(import.meta.url)));\n  } else {\n    throw new Error('No data directory found');\n  }\n}\n\n/**\n * The list of all known search parameter definition bundle file paths relative to the\n * `@medplum/definitions` package. Typically used in conjunction with `readJson`.\n */\nexport const SEARCH_PARAMETER_BUNDLE_FILES = [\n  'fhir/r4/search-parameters.json',\n  'fhir/r4/search-parameters-medplum.json',\n  'fhir/r4/search-parameters-uscore.json',\n];\n"],
  "mappings": "AAEA,OAAS,gBAAAA,MAAoB,KAC7B,OAAS,cAAAC,MAAkB,UAC3B,OAAS,WAAAC,EAAS,WAAAC,MAAe,YACjC,OAAS,iBAAAC,MAAqB,WAEvB,SAASC,EAASC,EAAuB,CAC9C,IAAMC,EAAeJ,EAAQK,EAAW,EAAGF,CAAQ,EACnD,OAAO,KAAK,MAAMN,EAAaO,EAAc,MAAM,CAAC,CACtD,CAEA,IAAIE,EAEG,SAASD,GAAqB,CACnC,GAAIC,EACF,OAAOA,EAGT,IAAMC,EAAaC,EAAc,EAM3BC,EAAgB,CAAC,KAAM,MAAO,SAAU,QAAQ,EACtD,QAAWC,KAAgBD,EAAe,CACxC,IAAME,EAAWX,EAAQO,EAAYG,CAAY,EAC3CE,EAAWZ,EAAQW,EAAU,MAAM,EACzC,GAAIb,EAAWc,CAAQ,EACrB,OAAAN,EAAgBK,EACTA,CAEX,CACA,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CAEA,SAASH,GAAwB,CAC/B,GAAI,OAAO,UAAc,IACvB,OAAOR,EAAQ,SAAS,EACnB,GAAI,YAAY,IACrB,OAAOA,EAAQD,EAAQE,EAAc,YAAY,GAAG,CAAC,CAAC,EAEtD,MAAM,IAAI,MAAM,yBAAyB,CAE7C,CAMO,IAAMY,EAAgC,CAC3C,iCACA,yCACA,uCACF",
  "names": ["readFileSync", "existsSync", "dirname", "resolve", "fileURLToPath", "readJson", "filename", "filenamePath", "getDataDir", "cachedDataDir", "currentDir", "getCurrentDir", "relativePaths", "relativePath", "fullPath", "fhirPath", "SEARCH_PARAMETER_BUNDLE_FILES"]
}
