import * as elIcons from '@element-plus/icons-vue'
import * as scIcons from '@/assets/icons'

function formatIcon(icon) {
	return icon.split(/(?=[A-Z])/).map(n => n.toLowerCase()).join('-')
}

function selectIcon(menuIcon) {
	const icon = menuIcon.split('-').map(str => str.slice(0, 1).toUpperCase() + str.slice(1)).join('')
	const allIcons = icons.map(i => i.icons).reduce((p, v) => p.concat(v)).map(i => formatIcon(i))
	return allIcons.filter(a => a == 'el-icon-' + formatIcon(icon) || a == 'sc-icon-' + formatIcon(icon))[0] || null
}

const icons = [{
	name: '默认',
	icons: Object.keys(elIcons).map(name => formatIcon(`ElIcon${name}`))
},
{
	name: '扩展',
	icons: Object.keys(scIcons.default).map(name => formatIcon(`ScIcon${name}`))
}]

// 图标选择器配置
export default { icons, selectIcon }