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OAGyC,SAAtC,EAAK,MAAM,EAAK,YAAY,OAC/B,GAAG,WAAW,KAAK,KAAK,EAAsB,GAElD,CAEJ,CAEA,IAAI,EAAoB,EAExB,GAAK,EAAS,CACZ,MAAM,EAAiB,cAAc,GAErC,GAAK,EAAK,QAAU,EAAe,OACjC,OAAO,KAGT,GAAK,IAAmB,EAAK,MAAM,EAAG,EAAe,QACnD,OAAO,KAGT,EAAoB,EAAkB,MAAM,EAAe,OAC7D,CAGA,MAAM,EAAW,KAAK,KAAK,EAAiB,GAAG,SAC/C,IAAI,EAEJ,IACE,EAAa,GAAG,aAAa,EAAU,OACzC,CAAE,MAAM,GACN,GAAoB,WAAf,EAAM,KACT,MAAM,EAGR,MAAM,EAAkB,KAAK,KAAK,EAAiB,GAAG,uBAAuB,UAE7E,IACE,EAAa,GAAG,aAAa,EAAiB,OAChD,CAAE,MAAM,GACN,GAAoB,WAAf,EAAM,KACT,MAAM,EAGR,MAAM,EAAgB,KAAK,KAAK,EAAiB,GAAG,cAAc,UAElE,IACE,EAAa,GAAG,aAAa,EAAe,OAC9C,CAAE,MAAM,GACN,GAAoB,WAAf,EAAM,KACT,MAAM,EAGR,OAAO,IACT,CACF,CACF,CAEA,MAAM,EAAgB,yGAGxB,mBAKQ,EAAgB,KAAK,KAAK,EAAsB,GAAG,SAGzD,OAFA,GAAG,cAAc,EAAe,GAEzB,IAAM,EAEjB,CAEA,QAAQ,wBAA0B","file":"/npm/vite-custom-icons-resolver@1.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vite-custom-icons-resolver@1.0.2/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')\n\nconst firstLetterToLowerCase = (word) => {\n  let Word = word[0].toLowerCase()\n\n  if ( word.length === 1 ) {\n    return Word\n  }\n\n  for ( let i = 1; i < word.length; i++ ) {\n    Word += word[i]\n  }\n\n  return Word\n}\n\nconst pascalToKebab = (camel) => {\n  let kebab = camel[0].toLowerCase()\n\n  if ( camel.length === 1 ) {\n    return kebab\n  }\n\n  for ( let i = 1; i < camel.length; i++ ) {\n    if ( camel[i] === camel[i].toUpperCase() ) {\n      kebab += '-' + camel[i].toLowerCase()\n    } else {\n      kebab += camel[i]\n    }\n\n  }\n\n  return kebab\n}\n\nconst kebabToPascal = (kebab) => {\n  let pascal = kebab[0].toUpperCase()\n\n  if ( kebab.length === 1 ) {\n    return pascal\n  }\n\n  let hyphenStep = false\n\n  for ( let i = 1; i < kebab.length; i++ ) {\n    if ( kebab[i] === '-' ) {\n      hyphenStep = true\n    } else if ( hyphenStep ) {\n      hyphenStep = false\n      pascal += kebab[i].toUpperCase()\n    } else {\n      pascal += kebab[i].toLowerCase()\n    }\n  }\n\n  return pascal\n}\n\nfunction viteCustomIconsResolver (options){\n  const defaultOptions = {\n    prefix: 'i',\n    iconsFolderPath: 'src/icons',\n  }\n\n  const {\n    prefix,\n    iconsFolderPath,\n  } = { ...defaultOptions, ...(options ? options : {}) }\n\n  let componentCounter = 0\n\n  return (name) => {\n    // Note: even if the name of icon component was specified in kebab,\n    // it is always passed pre-converted to pascal\n\n    const componentsFolderPath = path.join(iconsFolderPath, 'icon-components')\n\n    // Pre-cleaning of tmp-icon-components folder from '.vue' files\n    if ( componentCounter === 0 ) {\n      componentCounter++\n\n      let files\n      let tmpFolderExists = true\n\n      try { // Checking the folder for existence\n        files = fs.readdirSync(componentsFolderPath)\n      } catch(error) {\n        if ( error.code !== 'ENOENT' ) { // The folder does not exist\n          throw error\n        } else {\n          tmpFolderExists = false\n\n          fs.mkdirSync(componentsFolderPath)\n        }\n      }\n\n      if ( tmpFolderExists ) {\n        for (const file of files) {\n          if ( !file.includes('.') ) {\n            return\n          }\n\n          if ( file.slice(file.lastIndexOf('.')) === '.vue' ) {\n            fs.unlinkSync(path.join(componentsFolderPath, file))\n          }\n        }\n      }\n    }\n\n    let nameWithoutPrefix = name\n\n    if ( prefix ) {\n      const prefixInPascal = kebabToPascal(prefix)\n\n      if ( name.length <= prefixInPascal.length ) {\n        return null\n      }\n\n      if ( prefixInPascal !== name.slice(0, prefixInPascal.length) ) {\n        return null\n      }\n\n      nameWithoutPrefix = nameWithoutPrefix.slice(prefixInPascal.length)\n    }\n\n    // Icon path with file name in PascalCase\n    const iconPath = path.join(iconsFolderPath, `${nameWithoutPrefix}.svg`)\n    let svgContent\n\n    try { // Search for a file by name in the PascalCase\n      svgContent = fs.readFileSync(iconPath, 'utf8')\n    } catch(error) { // File in PascalCase not found\n      if ( error.code !== 'ENOENT' ) {\n        throw error\n      }\n\n      const iconPathInCamel = path.join(iconsFolderPath, `${firstLetterToLowerCase(nameWithoutPrefix)}.svg`)\n\n      try { // Search for a file by name in the camelCase\n        svgContent = fs.readFileSync(iconPathInCamel, 'utf8')\n      } catch(error) { // File in camelCase not found\n        if ( error.code !== 'ENOENT' ) {\n          throw error\n        }\n\n        const iconPathKebab = path.join(iconsFolderPath, `${pascalToKebab(nameWithoutPrefix)}.svg`)\n\n        try { // Search for a file by name in the kebab-case\n          svgContent = fs.readFileSync(iconPathKebab, 'utf8')\n        } catch(error) { // File in kebab-case not found\n          if ( error.code !== 'ENOENT' ) {\n            throw error\n          }\n\n          return null\n        }\n      }\n    }\n\n    const componentCode = `\n<template>\n<!-- This file was created automatically. You should not make changes to it! -->\n${svgContent}\n</template>\n`\n\n    // const componentPath = `${componentsFolderPath}/${nameWithoutPrefix}.vue`\n    const componentPath = path.join(componentsFolderPath, `${nameWithoutPrefix}.vue`)\n    fs.writeFileSync(componentPath, componentCode)\n\n    return '/' + componentPath\n  }\n}\n\nexports.viteCustomIconsResolver = viteCustomIconsResolver\n"]}