import * as JoinLines from '../JoinLines/JoinLines.js'
import * as AssetDir from '../AssetDir/AssetDir.js'

const getBackgroundUrl = (extensionPath, value) => {
  return `${AssetDir.assetDir}${value}`
}

export const getIconThemeCss = (iconTheme) => {
  const rules = []
  const iconDefinitions = iconTheme.json.iconDefinitions
  const extensionPath = iconTheme.extensionPath
  for (const [key, value] of Object.entries(iconDefinitions)) {
    const backgroundUrl = getBackgroundUrl(extensionPath, value)
    rules.push(`.FileIcon${key} { background-image: url(${backgroundUrl}) }`)
  }
  const rulesCss = JoinLines.joinLines(rules)
  return rulesCss
}
