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,QAEjB,CAOA,SAAS,uBAAuB,GAE9B,OADoB,mBACD,MAAK,GAAO,EAAI,WAAa,GAClD,CAEA,OAAO,QAAU,CACf,0BACA,gCACA,kCACA,0BACA,sBACA","file":"/npm/image-wutheringwaves@1.1.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/image-wutheringwaves@1.1.1/src/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","const fs = require('fs');\nconst path = require('path');\nconst packageJson = require('../package.json');\n\n/**\n * @type {string}\n */\nconst imageSetName = packageJson.name.replace(/^@.*\\//, ''); // Removes scope if present\nconst imageSetDir = path.join(__dirname, '..', 'public', 'images');\nconst metadataPath = path.join(__dirname, '..', 'src', 'image-metadata.json');\nconst tagConfigPath = path.join(__dirname, '..', 'src', 'tag-config.json');\n\n/**\n * @typedef {Object} ImageMetadata\n * @property {string} filename - The name of the image file\n * @property {string} label - User-defined label for the image\n * @property {string[]} tags - Array of tag names associated with the image\n */\n\n/**\n * @typedef {Object} Tag\n * @property {string} name - The name of the tag (used as identifier)\n * @property {string} title - The display title of the tag\n * @property {string} description - User-defined description of the tag\n */\n\n/**\n * @typedef {Object} TagConfig\n * @property {Tag[]} subject - Tags related to the subject of the image\n * @property {Tag[]} version - Tags related to the version of the image set\n * @property {Tag[]} general - General tags and newly added tags\n */\n\n/**\n * Recursively gets a list of image files in the given directory.\n * @param {string} [dir] - The directory to search (defaults to imageSetDir).\n * @returns {string[]} An array of relative file paths.\n */\nfunction getImageList(dir = imageSetDir) {\n  /** @type {string[]} */\n  let results = [];\n  const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n  for (const entry of entries) {\n    const fullPath = path.join(dir, entry.name);\n    if (entry.isDirectory()) {\n      results = results.concat(getImageList(fullPath));\n    } else if (entry.isFile() && entry.name.endsWith('.webp')) {\n      results.push(path.relative(imageSetDir, fullPath));\n    }\n  }\n\n  return results;\n}\n\n/**\n * Gets the name of the image set.\n * @returns {string} The name of the image set.\n */\nfunction getImageSetName() {\n  return imageSetName;\n}\n\n/**\n * Gets the metadata for all images.\n * @returns {ImageMetadata[]} An array of image metadata objects.\n */\nfunction getImageMetadata() {\n  try {\n    const data = fs.readFileSync(metadataPath, 'utf8');\n    const metadata = JSON.parse(data);\n    const allTags = getAllTags();\n\n    return metadata.map(item => ({\n      ...item,\n      tags: item.tags.map(tagName => {\n        const fullTag = allTags.find(t => t.name === tagName);\n        return fullTag || { name: tagName, title: tagName, description: '' };\n      })\n    }));\n  } catch (error) {\n    console.error('Error reading metadata:', error);\n    return [];\n  }\n}\n\n/**\n * Gets the tag configuration.\n * @returns {TagConfig} The tag configuration object.\n */\nfunction getTagConfig() {\n  try {\n    const data = fs.readFileSync(tagConfigPath, 'utf8');\n    return JSON.parse(data);\n  } catch (error) {\n    console.error('Error reading tag config:', error);\n    return { subject: [], version: [], general: [] };\n  }\n}\n\n/**\n * Gets all available tags across all categories.\n * @returns {Tag[]} An array of all tags.\n */\nfunction getAllTags() {\n  const tagConfig = getTagConfig();\n  return [\n    ...tagConfig.subject,\n    ...tagConfig.version,\n    ...tagConfig.general\n  ];\n}\n\n/**\n * Gets metadata for a specific image.\n * @param {string} imagePath - The relative path of the image.\n * @returns {ImageMetadata|undefined} The metadata for the specified image, or undefined if not found.\n */\nfunction getImageMetadataByPath(imagePath) {\n  const allMetadata = getImageMetadata();\n  return allMetadata.find(img => img.filename === imagePath);\n}\n\nmodule.exports = {\n  getImageList,\n  getImageSetName,\n  getImageMetadata,\n  getTagConfig,\n  getAllTags,\n  getImageMetadataByPath,\n};\n"]}